Add a custom field to user profiles in the admin area.
add_action('show_user_profile', 'codebykp_add_custom_user_profile_fields');
add_action('edit_user_profile', 'codebykp_add_custom_user_profile_fields');
function codebykp_add_custom_user_profile_fields($user) {
?>
<h3>Extra Profile Information</h3>
<table class="form-table">
<tr>
<th><label for="custom_field">Custom Field</label></th>
<td>
<input type="text" name="custom_field" id="custom_field" value="<?php echo esc_attr(get_user_meta($user->ID, 'custom_field', true)); ?>" class="regular-text" />
</td>
</tr>
</table>
<?php
}
add_action('personal_options_update', 'codebykp_save_custom_user_profile_fields');
add_action('edit_user_profile_update', 'codebykp_save_custom_user_profile_fields');
function codebykp_save_custom_user_profile_fields($user_id) {
update_user_meta($user_id, 'custom_field', sanitize_text_field($_POST['custom_field']));
}





















