Add Name field on User Registration Page

  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 9, 2015 at 1:24 am

    It is very sad to say that, User registration page does not contain First Name and Last Name option. Even though, we can allow, firstname and lastname in #MyAccountDetails but not at Registration Page ?

    We know, we can do this by something like, hooks or modifying page-register.php

    Why not add in a theme option ? And if you insist me to add as registration-fields, there behaviours are odd. Look screenshot, what they, if I add them by custom-field in registration.

    Can anyone give me the hooks or php code help to achieve, so that, I can use that name in email-template.

    Attachments:
    You must be logged in to view attached files.
  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 9, 2015 at 1:25 am

    firstname datebase key is fname and lastname is lname


  • Josh
    Super Guru 13,875 points
    March 9, 2015 at 8:09 am

    Hello Hemanta
    Here is what you can do.In the file page-register.php move this line above the first form-group class
    [code title=”code”]
    <?php echo str_replace(“col-md-3″,”col-md-5”,str_replace(“col-md-7″,”col-md-7”,$CORE->CORE_FIELDS())); ?>
    [/code]
    That will ensure the custom fields created (First Name and Last Name) move above the default fields
    Finally in the fields you created (First Name and Last Name) make sure you have set the option ‘User can Edit?’ to ‘no’ this will prevent the fields from duplicating in My Account Details section

    Attachments:
    You must be logged in to view attached files.
  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 9, 2015 at 11:07 am

    Hi, I want the user to able to edit their Name. So, I can’t set them to not editable.

    And I should be able to call their name by wordpress wp_get_current_user() function.
    [code]
    <?php
    $current_user = wp_get_current_user();
    /**
    * @example Safe usage: $current_user = wp_get_current_user();
    * if ( !($current_user instanceof WP_User) )
    * return;
    */
    echo ‘Username: ‘ . $current_user->user_login . ‘<br />’;
    echo ‘User email: ‘ . $current_user->user_email . ‘<br />’;
    echo ‘User first name: ‘ . $current_user->user_firstname . ‘<br />’;
    echo ‘User last name: ‘ . $current_user->user_lastname . ‘<br />’;
    echo ‘User display name: ‘ . $current_user->display_name . ‘<br />’;
    echo ‘User ID: ‘ . $current_user->ID . ‘<br />’;
    ?>[/code]

    Above code is from wp-codex. Here we only have user_login and email available right now. I want this field, user_firstname,user_lastname and display_name and users are allowed to edit them.

  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 9, 2015 at 9:19 pm

    I really want to add this.


  • Josh
    Super Guru 13,875 points
    March 10, 2015 at 12:04 pm

    I suggest you hire someone if your not sure how to go about

  • Mark Fail
    Mark Fail
    Super Guru 13,013 points
    March 10, 2015 at 12:22 pm

    simply disable the first/last in your members area from the general setup -> my account tab and create your own first/lastname fields under general setup -> registration fields.

  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 10, 2015 at 12:39 pm

    I did that, it didn’t shows the First name/last name in the #MyAccountDetails tab.

    It shows only the box for first_name and last_name and it is blank. Even though I have entered the firstname and lastname.

    And what should be the database name for Firstname and lastname , so that I can include it in the Welcome email ?

  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 10, 2015 at 12:45 pm

    One more thing, currently the login section need username and password. I want to make it username/email and password i.e. most of us don’t bother about the username, so we should also have an option to use email in place of username( or anyone of these.)

    I think this should not be a much more complicated, few lines to edit.

  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 10, 2015 at 1:04 pm

    Hi Mark,

    If I add name through registration field, what should be the db_key so that it shows in the users.php Name option.

    See screenshot.

    Attachments:
    You must be logged in to view attached files.
  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 11, 2015 at 9:30 am

    Hi Mark, any suggestion on these ?

  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 20, 2015 at 12:24 pm

    Anyone there who need this ?

  • Clive
    Clive
    Super Guru 1,818 points
    March 20, 2015 at 12:29 pm

    Not really, but thanks for sharing 🙂

  • Hemanta Chakladar
    Hemanta Chakladar
    Super Guru 1,710 points
    March 20, 2015 at 12:33 pm

    But I need this to use First Name and Last Name in Email Newsletter.

  • Michael
    Michael
    Senior Member 141 points
    June 2, 2015 at 2:48 pm

    Everybody needs this, Hemanta ))

    Obviously, creating your own first/last name fields (general setup -> registration fields) doesn’t work.

    You enter info in those fields, but the system doesn’t save them.

Viewing 15 posts - 1 through 15 (of 17 total)

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes