• Resolved candell

    (@candell)


    Hi

    I followed http://docs.thememylogin.com/adding-extra-registration-fields/ to add the first and last name to the registration form. I added the register-form.php pag with the correct code and the fields show – great.

    But, they aren’t saving. I created the theme-my-login-custom.php file and added

    <?php
    
    function tml_registration_errors( $errors ) {
    	if ( empty( $_POST['first_name'] ) )
    		$errors->add( 'empty_first_name', '<strong>ERROR</strong>: Please enter your first name.' );
    	if ( empty( $_POST['last_name'] ) )
    		$errors->add( 'empty_last_name', '<strong>ERROR</strong>: Please enter your last name.' );
    	return $errors;
    }
    add_filter( 'registration_errors', 'tml_registration_errors' );
    
    function tml_user_register( $user_id ) {
    	if ( !empty( $_POST['first_name'] ) )
    		update_user_meta( $user_id, 'first_name', $_POST['first_name'] );
    	if ( !empty( $_POST['last_name'] ) )
    		update_user_meta( $user_id, 'last_name', $_POST['last_name'] );
    }
    add_action( 'user_register', 'tml_user_register' );

    to it and saved in the plugins folder.

    But new registrations aren’t showing a name.

    Thanks for any help

Viewing 1 replies (of 1 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    That’s because that documentation is actually outdated – sorry. Swicth tml_user_register for user_register.

Viewing 1 replies (of 1 total)

The topic ‘Adding name to registration form’ is closed to new replies.