do_action( 'edit_user_profile_update', int $user_id )

Fires before the page loads on the ‘Edit User’ screen.


Parameters Parameters

$user_id

(int) The user ID.


Top ↑

More Information More Information

This action hook is generally used to save custom fields that have been added to the WordPress profile page.

This hook only triggers when a user is viewing another user’s profile page (not their own). If you want to apply your hook to ALL profile pages (including the current user), you need to use the personal_options_update hook.

Note on the the html <input> element name attribute for the “custom meta field”:
Consider the example:
update_user_meta($user_id, 'custom_meta_key', $_POST['custom_meta_key']);
Make sure that you give a different key name for the $_POST data key and the actual user meta key. If you use the same key for both, WordPress for some reason empties the value posted under that key and you’ll always get an empty value in $_POST[‘custom_meta_key’]. To prevent this, you may change the text in the html input element name attribute and append a suffix. After changing, you $_POST data for the custom meta field will be accessible in $_POST[‘custom_meta_key_data’] and shall pass the data properly.


Top ↑

Source Source

File: wp-admin/user-edit.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
2.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by stevenlinx

    Example migrated from Codex:

    This example shows how to save a custom field named ‘your_field‘.

    function update_extra_profile_fields($user_id) {
         if ( current_user_can('edit_user',$user_id) )
             update_user_meta($user_id, 'my_custom_field', $_POST['your_field']);
    }
    add_action('edit_user_profile_update', 'update_extra_profile_fields');
    

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