Title: Adding Fields to Registration
Last modified: May 14, 2018

---

# Adding Fields to Registration

 *  Resolved [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/)
 * Hello I am trying to further extend the registration form. I have added both “
   first_name” and “last_name” as displayed by wordpress but for some reason it 
   seems as though the update_user_meta is not saving whatsoever.
 * I have created the file wp-content/plugins/theme-my-login-custom.php
    I have 
   created wp-content/themes/child/register-form.php
 * This is the code I am using on the register page:
 *     ```
       <div class="tml-user-first-last-name-wrap" style="margin-bottom: 25px;">
       	        <span style="width:50%; padding-left: 25px; padding-right: 1px; float:left;"><input type="text" placeholder="First Name" name="first_name" id="first_name<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'first_name' ); ?>" size="20" />
       	        <label for="first_name<?php $template->the_instance(); ?>"><?php _e( '', 'theme-my-login' ) ?></label>
       	    </span>
       	   	    <span style="width:50%; padding-left: 1px; padding-right: 25px; float:right;"><input type="text" placeholder="Last Name" name="last_name" id="last_name<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'last_name' ); ?>" size="20"  />
       	   	    <label for="last_name<?php $template->the_instance(); ?>"><?php _e( '', 'theme-my-login' ) ?></label>
       	   	</span>
       	   	<br>
       	   	</div>
       ```
   
 * This is the code I have in the custom file:
 *     ```
       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' );
       ```
   
 * Any ideas?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-fields-to-registration-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278195)
 * Not being funny, but you do have the opening `<?php` tag in `theme-my-login-custom.
   php`, right?
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278243)
 * lol. Yes I do.
 *  Plugin Author [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278252)
 * Try setting a lower priority on the `user_register` action:
 *     ```
       add_action( 'user_register', 'tml_user_register', 5 );
       ```
   
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278275)
 * that’s a negative. I previously tried the
    `die (it works!)` I saw from a previous
   discussion, It did white the page out, but its not updating for whatever reason.
 *  Plugin Author [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278285)
 * Check if the data actually exists by putting this in the `tml_user_register` 
   function:
 *     ```
       print_r($_POST);
       die;
       ```
   
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278294)
 * Good news is it does exist
 * `Array ( [first_name] => 21 [last_name] => 21 [user_email] => 21@21.com [user_login]
   => 21 [pass1] => 212121 [pass2] => 212121 [aiowps-captcha-string-info] => vwzup4m6t8[
   aiowps-captcha-temp-string] => 1526304894 [aiowps-captcha-answer] => 13 [wp-submit]
   => Sign up [redirect_to] => https://christianjournal.net/your-profile/login/?
   registration=complete [instance] => [action] => register [user_pass] => 212121)`
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278298)
 * Good news it does exist. it gave me the array and displayed all the corresponding
   info I can’t post it because it wont let me
 *  Plugin Author [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278305)
 * Only thing I can think is maybe something else is overwriting the meta after 
   it is updated or preventing it from updating in the first place. Try disabling
   any other plugins.
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278345)
 * You’d be right. I just re-deactivated everything and there it is. What could 
   write over it?
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278347)
 * Could paid memberships pro?
 *  Plugin Author [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278351)
 * Quite possibly.
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278398)
 * AH.Okay, thank you for your help!!
 *  Thread Starter [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * (@nateb2127)
 * [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278479)
 * Good news is its not All in One WordPress Security or Paid Memberships Pro..
   
   Bad news is it is W3 Total Cache. I have forced the site not to cache the register
   page but it still seems to not work.
 * Update I know what it is: I forgot to tell w3tc to not cache: theme-my-login-
   custom.php

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Adding Fields to Registration’ is closed to new replies.

 * ![](https://ps.w.org/theme-my-login/assets/icon-256x256.png?rev=1891232)
 * [Theme My Login](https://wordpress.org/plugins/theme-my-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/theme-my-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/theme-my-login/)
 * [Active Topics](https://wordpress.org/support/plugin/theme-my-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/theme-my-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/theme-my-login/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [first name](https://wordpress.org/support/topic-tag/first-name/)
 * [last name](https://wordpress.org/support/topic-tag/last-name/)
 * [register](https://wordpress.org/support/topic-tag/register/)

 * 13 replies
 * 2 participants
 * Last reply from: [nateb2127](https://wordpress.org/support/users/nateb2127/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/adding-fields-to-registration-2/#post-10278479)
 * Status: resolved