• Hi,

    Into the registrer form, I want to add fields (lirtsname, lastname, town, country).
    How can I do that ?

    Thanks
    Ludovic

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

    (@jfarthing84)

    Thread Starter RenaiSens

    (@renaisens)

    Thanks Jeff,

    It doesn’t run.
    When I go to the register page, I don’t see the added fields
    https://flammesjumelles.world/register/

    1 –
    I add this code into the register-form.php file (between <form> and </form>) that is into the root of my child theme (into the main theme it’s the same – it doesn’t run).

    ———- code ———-
    <p>
    <label for=”first_name<?php $template->the_instance(); ?>”><?php _e( ‘First name’, ‘theme-my-login’ ) ?></label>
    <input type=”text” name=”first_name” id=”first_name<?php $template->the_instance(); ?>” class=”input” value=”<?php $template->the_posted_value( ‘first_name’ ); ?>” size=”20″ tabindex=”20″ />
    </p>
    <p>
    <label for=”last_name<?php $template->the_instance(); ?>”><?php _e( ‘Last name’, ‘theme-my-login’ ) ?></label>
    <input type=”text” name=”last_name” id=”last_name<?php $template->the_instance(); ?>” class=”input” value=”<?php $template->the_posted_value( ‘last_name’ ); ?>” size=”20″ tabindex=”20″ />
    </p>

    2 – And I have theme-my-login-custom.php file into the root of plugins folder with this single code :
    ——– code ———
    <?php

    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’ );
    ?>

    ———- Info ———
    I use multisite and WP 4.6

    Thanks for your help.
    Ludovic

    Plugin Author Jeff Farthing

    (@jfarthing84)

    The code/process would actually be a little different for multisite. Unfortunately, I haven’t yet documented doing so.

    Hi
    please if i want to do the same add feilds, i have to know php?
    i tried searching if there is something ready i cant find please can u suggest?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add fields’ is closed to new replies.