do_action( 'edit_user_profile', WP_User $profileuser )

Fires after the ‘About the User’ settings table on the ‘Edit User’ screen.


Parameters Parameters

$profileuser

(WP_User) The current WP_User object.


Top ↑

More Information More Information

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.


Top ↑

Source Source

File: wp-admin/user-edit.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by 1994rstefan

    This action can be used to add a form to the backend user editing screen and save some additional user meta data.

    For example to add a field for the users birthday:

    function userMetaBirthdayForm(WP_User $user) {
    ?>
    <h2>Birthday</h2>
    	<table class="form-table">
    		<tr>
    			<th><label for="user_birthday">Birthday</label></th>
    			<td>
    				<input
    					type="date"
    					value="<?php echo esc_attr(get_user_meta($user->ID, 'birthday', true)); ?>"
    					name="user_birthday"
    					id="user_birthday"
    				>
    				<span class="description">Some description to the input</span>
    			</td>
    		</tr>
    	</table>
    <?php
    }
    add_action('show_user_profile', 'userMetaBirthdayForm'); // editing your own profile
    add_action('edit_user_profile', 'userMetaBirthdayForm'); // editing another user
    add_action('user_new_form', 'userMetaBirthdayForm'); // creating a new user
    
    function userMetaBirthdaySave($userId) {
    	if (!current_user_can('edit_user', $userId)) {
    		return;
    	}
    
    	update_user_meta($userId, 'birthday', $_REQUEST['user_birthday']);
    }
    add_action('personal_options_update', 'userMetaBirthdaySave');
    add_action('edit_user_profile_update', 'userMetaBirthdaySave');
    add_action('user_register', 'userMetaBirthdaySave');
    
  2. Skip to note 2 content
    Contributed by stevenlinx

    Example migrated from Codex:

    /**
     * Show custom user profile fields
     * 
     * @param  object $profileuser A WP_User object
     * @return void
     */
    function custom_user_profile_fields( $profileuser ) {
    ?>
    	<table class="form-table">
    		<tr>
    			<th>
    				<label for="user_location"><?php esc_html_e( 'Location' ); ?></label>
    			</th>
    			<td>
    				<input type="text" name="user_location" id="user_location" value="<?php echo esc_attr( get_the_author_meta( 'user_location', $profileuser->ID ) ); ?>" class="regular-text" />
    				<br><span class="description"><?php esc_html_e( 'Your location.', 'text-domain' ); ?></span>
    			</td>
    		</tr>
    	</table>
    <?php
    }
    add_action( 'show_user_profile', 'custom_user_profile_fields', 10, 1 );
    add_action( 'edit_user_profile', 'custom_user_profile_fields', 10, 1 );
    

You must log in before being able to contribute a note or feedback.