Include custom wordpress field in registration
-
Hi,
I would like users to submit phone number on registration and automatically save it in a WordPress field.This should be only visible for admins, and therefore, the xProfile fields won’t work. To create a user the user fill out this form with password and email (Username is created programmatically).
I would like the phone number field there as well, but I’m not sure how to update the field at submission.
I tried to add the field with this code:<input type="text" name="phone" id="phone" value="" class="regular-text" <?php bp_form_field_attributes('phone'); ?>
But the field is blank when I check in WP admin. Any idea how I can do this?If i click to edit a user in WP admin I want the number to be added to this field.
I followed a tutorial to create the field, and added it to my function file with this code:
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=”phone”>Telefon</label></th>
<td>
<input type=”text” name=”phone” id=”phone” value=”<?php echo esc_attr( get_the_author_meta( ‘phone’, $user->ID ) ); ?>” class=”regular-text” /><br />
<span class=”description”>Vennligst angi ditt telefonummer slik ati </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’ );function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( ‘edit_user’, $user_id ) )
return false;update_usermeta( $user_id, ‘phone’, $_POST[‘phone’] );
}`
- The topic ‘Include custom wordpress field in registration’ is closed to new replies.