WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/edit user profile

This page is marked as incomplete. You can help Codex by expanding it.

Contents

Description

This action hook is typically used to output new fields or data to the bottom of WordPress's user profile pages.

This hook only triggers when a user is viewing another users profile page (not their own). If you want to apply your hook to ALL profile pages (including the current user) then you also need to use the show_user_profile hook.

Parameters

$user
(object) (optional) The WP_User object of the user being edited.
Default: None

Example

/**
 * Show custom user profile fields
 * @param  obj $user The user object.
 * @return void
 */
function numediaweb_custom_user_profile_fields($user) {
?>
<table class="form-table">
<tr>
	<th>
		<label for="tc_location"><?php _e('Location'); ?></label>
	</th>
	<td>
		<input type="text" name="tc_location" id="tc_location" value="<?php echo esc_attr( get_the_author_meta( 'tc_location', $user->ID ) ); ?>" class="regular-text" />
		<br><span class="description"><?php _e('Your location.', 'travelcat'); ?></span>
	</td>
</tr>
<tr>
	<th>
		<label for="tc_favorites"><?php _e('Favorites', 'travelcat'); ?></label>
	</th>
	<td>
		<input type="text" name="tc_favorites" id="tc_favorites" value="<?php echo esc_attr( get_the_author_meta( 'tc_favorites', $user->ID ) ); ?>" class="regular-text" />
		<br><span class="description"><?php _e('Can you share a few of your favorite places to be or to stay?', 'travelcat'); ?></span>
		<br><span class="description"><?php _e('Separate by commas.', 'travelcat'); ?></span>
	</td>
</tr>
<tr>
	<th>
		<label for="tc_travel_map"><?php _e('Travel map', 'travelcat'); ?></label>
	</th>
	<td>
		<input type="text" name="tc_travel_map" id="tc_travel_map" value="<?php echo esc_attr( get_the_author_meta( 'tc_travel_map', $user->ID ) ); ?>" class="regular-text" />
		<br><span class="description"><?php _e('Been there / Going there within a year / Wish list.', 'travelcat'); ?></span>
		<br><span class="description"><?php _e('Separate by commas.', 'travelcat'); ?></span>
	</td>
</tr>
</table>
<?php
}
add_action('show_user_profile', 'numediaweb_custom_user_profile_fields');
add_action('edit_user_profile', 'numediaweb_custom_user_profile_fields');

Source File

The edit_user_profile hook is located in /wp-admin/user-edit.php

Related

Return to Plugin API/Action Reference