Custom Fields on Registration Not Appearing
-
Help please! I am running myself in circles but think I am finally really close.
I have read and re-read the tons of advice in the forums and google and am finally to what I think it the final ‘missing link’.
I am using TML for my login, profile, etc… screens and all is good except for this one final issue.
I needed to add 2 custom fields to my registration screen. I have modified the functions.php and I now have the custom fields appearing on the profile and I have added them to the registration screen. If I update them on the TML profile screen then they appear under the custom fields on the word press profile screen when I am logged in as admin and go to edit the user. HOWEVER, when they enter the information during registration, the information is not captured. I tried using every ‘registration’ action I could and none of them are working to actually capture the data during the original registration.
I am sure it is something really simple or stupid on my part, but would really appreciate somebody setting me in the right direction.
I got the basics on the code from another post and have been trying to modify it to capture the data during registration also with no luck. Here is the code I currently have in:
add_action( ‘show_user_profile’, ‘my_show_extra_profile_fields’ );
add_action( ‘edit_user_profile’, ‘my_show_extra_profile_fields’ );function my_show_extra_profile_fields( $user ) { ?>
<h3>Extra profile information</h3>
<table class=”form-table”>
<tr>
<th><label for=”cheerleader_name”>Cheerleader’s Name</label></th><td>
<input type=”text” name=”cheerleader_name” id=”cheerleader_name” value=”<?php echo esc_attr( get_the_author_meta( ‘cheerleader_name’, $user->ID ) ); ?>” class=”regular-text” />
<span class=”description”>Please enter the name of the cheerleader you are associated with.</span>
</td>
</tr><tr>
<th><label for=”phone_number”>Phone Number</label></th><td>
<input type=”text” name=”phone_number” id=”phone_number” value=”<?php echo esc_attr( get_the_author_meta( ‘phone_number’, $user->ID ) ); ?>” class=”regular-text” />
<span class=”description”>Please enter your phone number.</span>
</td>
</tr><tr>
<th><label for=”first_name”>First Name</label></th><td>
<input type=”text” name=”first_name” id=”first_name” value=”<?php echo esc_attr( get_the_author_meta( ‘first_name’, $user->ID ) ); ?>” class=”regular-text” />
<span class=”description”>First Name</span>
</td>
</tr><tr>
<th><label for=”last_name”>Last Name</label></th>
<td>
<input type=”text” name=”last_name” id=”last_name” value=”<?php echo esc_attr( get_the_author_meta( ‘last_name’, $user->ID ) ); ?>” class=”regular-text” />
<span class=”description”>Last Name</span>
</td>
</tr>
</table>
<?php }add_action( ‘personal_options_update’, ‘my_save_extra_profile_fields’ );
add_action( ‘edit_user_profile_update’, ‘my_save_extra_profile_fields’ );
add_action( ‘user_register’, ‘my_save_extra_profile_fields’ );function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( ‘edit_user’, $user_id ) )
return false;/* Copy and paste this line for additional fields. Make sure to change ‘twitter’ to the field ID. */
update_usermeta( $user_id, ‘cheerleader_name’, $_POST[‘cheerleader_name’] );
update_usermeta( $user_id, ‘phone_number’, $_POST[‘phone_number’] );
update_usermeta( $user_id, ‘first_name’, $_POST[‘first_name’] );
update_usermeta( $user_id, ‘last_name’, $_POST[‘last_name’] );
}Thanks!!
The topic ‘Custom Fields on Registration Not Appearing’ is closed to new replies.