WordPress.org

Ready to get started?Download WordPress

Forums

Theme My Login
Problem with extra-fields (2 posts)

  1. atwave
    Member
    Posted 1 year ago #

    Hi,
    I added the user login / signup panel using your awesome plugin.

    I read some old posts regarding the extra fields but I’m going crazy with my owns.

    I put in register-form.php the following code (within the registration form):

    <input type="text" name="user_login" id="user_loginthe_instance(); ?>” class=”input” value=”Nome e Cognome” size=”20″ />
    
    <input type="text" name="user_email" id="user_emailthe_instance(); ?>” class=”input” value=”Email” size=”20″ />
    
    <input type="text" name="user_telefono" id="user_telefonothe_instance(); ?>” class=”input” value=”Telefono” size=”20″ />

    Moreover, I added the following code to the theme-my-login-custom.php file:
    . for each field I check that it’s not empty and it’s not equal to the placeholder.

    add( ‘empty_first_name’, ‘Per favore, inserisci nome e cognome.’ );
    if ( empty( $_POST['user_email'] ) || ($_POST['user_email'] === ‘Email’) )
    $errors->add( ‘empty_email’, “Per favore, inserisci l’indirizzo email” );
    if ( empty( $_POST['user_telefono'] ) || ($_POST['user_telefono'] === ‘Telefono’) )
    $errors->add( ‘user_telefono’, ‘Per favore, inserisci il numero di telefono’ );
    return $errors;
    }
    add_filter( ‘registration_errors’, ‘tml_registration_errors’ );
    
    function tml_user_register( $user_id ) {
    if ( !empty( $_POST['user_login'] ) && !($_POST['user_login'] === ‘Nome e Cognome’) )
    update_user_meta( $user_id, ‘user_login’, $_POST['user_login'] );
    if ( !empty( $_POST['user_email'] ) && !($_POST['user_email'] === ‘Email’) )
    update_user_meta( $user_id, ‘user_email’, $_POST['user_email'] );
    if ( !empty( $_POST['user_telefono'] ) && !($_POST['user_telefono'] === ‘Telefono’) )
    update_user_meta( $user_id, ‘user_telefono’, $_POST['user_telefono'] );
    }
    add_action( ‘user_register’, ‘tml_user_register’ );
    ?>

    The incredible thing is that the validation works for the user_login and user_email fields but not for the user_telefono.

    I’m very sorry for this noob question but I’m going crazy!

    Thanks,
    Ennio

    http://wordpress.org/extend/plugins/theme-my-login/

    [Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged by the forum's parser.]

  2. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    Try using equal (==) instead of identical (===) when checking to see if it matches the placeholder value.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic