I use the following to add and display new user meta fields on the user profile editor screen but when I click the update button, the values don't change:
function extra_user_profile_fields( $user ) { ?>
<table class="form-table">
<tr>
<th><label for="save_post_external"><?php _e("Save posts external"); ?></label></th>
<td>
<input type="text" name="save_post_external" id="save_post_external" value="<?php echo esc_attr( get_the_author_meta( 'save_post_external', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="save_post_internal"><?php _e("Save posts internal"); ?></label></th>
<td>
<input type="text" name="save_post_internal" id="save_post_internal" value="<?php echo esc_attr( get_the_author_meta( 'save_post_internal', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<?php }
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) {
return false;
}
update_user_meta( $user_id, 'Save Posts', $_POST['save_post_external'] );
update_user_meta( $user_id, 'Save Posts', $_POST['save_post_internal'] );
}