Users

Adding and using custom user profile fields

Function Reference/update user meta « WordPress Codex

<?php
/* =USER Extra Fields (Pilot check dates) */
// the_author_meta( $meta_key, $user_id );
add_action( 'show_user_profile', 'nwa_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'nwa_show_extra_profile_fields' );

function nwa_show_extra_profile_fields( $user ) { ?>

	<h3>Pilot Checks</h3>

	<table class="form-table">
		<tr>
			<td>
				<span class="description">Dates when last done:</span>
			</td>
			<th><label for="pilot_checkride">135 Checkride</label></th>
			<td>
				<input type="text" name="pilot_checkride" id="pilot_checkride" value="<?php echo esc_attr( get_the_author_meta( 'pilot_checkride', $user->ID ) ); ?>" class="regular-text" /><br />
			</td>
		</tr>
		<tr>
			<th><label for="pilot_med">Class 2 Medical</label></th>
			<td>
				<span class="description">Dates when last done:</span>
				<input type="text" name="pilot_med" id="pilot_med" value="<?php echo esc_attr( get_the_author_meta( 'pilot_med', $user->ID ) ); ?>" class="regular-text" /><br />
			</td>
		</tr>
		<tr>
			<th><label for="pilot_osa">OSA</label></th>
			<td>
				<input type="text" name="pilot_osa" id="pilot_checkride" value="<?php echo esc_attr( get_the_author_meta( 'pilot_osa', $user->ID ) ); ?>" class="regular-text" /><br />
			</td>
		</tr>
	</table>
<?php }

add_action( 'personal_options_update', 'nwa_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'nwa_save_extra_profile_fields' );

function nwa_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 to the field ID. */
	update_user_meta( $user_id, 'pilot_checkride', $_POST['pilot_checkride'] );
	update_user_meta( $user_id, 'pilot_med', $_POST['pilot_med'] );
	update_user_meta( $user_id, 'pilot_osa', $_POST['pilot_osa'] );
}
?>