Add an extra field, like a job title or phone number, to the user profile screen and save it with the user.
function nahnu_user_job_title_field( WP_User $user ): void {
?>
<h2>Extra details</h2>
<table class="form-table" role="presentation">
<tr>
<th><label for="nahnu_job_title">Job title</label></th>
<td>
<input type="text" name="nahnu_job_title" id="nahnu_job_title" class="regular-text"
value="<?php echo esc_attr( get_user_meta( $user->ID, 'nahnu_job_title', true ) ); ?>">
</td>
</tr>
</table>
<?php
}
add_action( 'show_user_profile', 'nahnu_user_job_title_field' );
add_action( 'edit_user_profile', 'nahnu_user_job_title_field' );
function nahnu_save_user_job_title( int $user_id ): void {
if ( ! current_user_can( 'edit_user', $user_id ) || ! isset( $_POST['nahnu_job_title'] ) ) {
return;
}
// WordPress checks the profile form's nonce before these actions run.
update_user_meta( $user_id, 'nahnu_job_title', sanitize_text_field( wp_unslash( $_POST['nahnu_job_title'] ) ) );
}
add_action( 'personal_options_update', 'nahnu_save_user_job_title' );
add_action( 'edit_user_profile_update', 'nahnu_save_user_job_title' );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
WordPress profiles have a few built-in fields, like name, website and bio. If you need more, for a team page or a member directory, you can add your own without a plugin.
show_user_profile adds the field to your own profile, and edit_user_profile adds it when an admin edits someone else. The field’s value is loaded with get_user_meta().
When the form is saved, personal_options_update or edit_user_profile_update runs. The save function checks the current user can edit that profile, cleans the text with sanitize_text_field() and stores it as user meta.
get_user_meta( $user_id, 'nahnu_job_title', true ), and escape it with esc_html().type="tel" or type="url" and esc_url_raw() for URLs.Open Users → Profile. Fill in “Job title”, save, and check the value is still there after reloading.