• Resolved michibahn

    (@michibahn)


    I’ve resolved the issue. I had to put all the codes in my function.php

    =======================

    Hi,

    I would like to add the FIRST NAME and LAST NAME fields on my User Registration so I followed the procedures on the TML docs. I created the theme-my-login-custom.php file and placed the codes below to allow the new user to enter his First name and Last name. However, he can still register without entering the First and Last name. Also, even if he enters the First name and Last name, it doesn’t show the name on the USERS section in my WP backend. I can only see the username and email fields.

    function tml_registration_errors( $errors ) {
    if ( empty( $_POST[‘first_name’] ) )
    $errors->add( ’empty_first_name’, ‘ERROR: Please enter your first name.’ );
    if ( empty( $_POST[‘last_name’] ) )
    $errors->add( ’empty_last_name’, ‘ERROR: 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’ );

    • This topic was modified 7 years ago by michibahn. Reason: issue is resolved
Viewing 1 replies (of 1 total)
  • Hello Michibahn,

    can you tell me, how you solved the issue with the Registration with firstname und surname?
    Can you post me your theme-my-login-custom.php file??

    Thanks Baumi

Viewing 1 replies (of 1 total)
  • The topic ‘Question on theme-my-login-custom.php’ is closed to new replies.