Fires after the user has been updated and emails have been sent.
Parameters
$user_id
int- The ID of the user that was just updated.
$userdata
array- The array of user data that was updated.
$userdata_raw
array- The unedited array of user data that was updated.
Source
do_action( 'wp_update_user', $user_id, $userdata, $userdata_raw );
Changelog
Version | Description |
---|---|
6.3.0 | Introduced. |
Here’s an example code snippet to demonstrate the usage of the
do_action
function with the'wp_update_user'
action in a WordPress context:Explanation of the code:
custom_user_update_action
that takes three parameters:$user_id
,$userdata
, and$userdata_raw
. Inside this function, you can write any custom code you want to execute when a user’s information is updated. In this example, we’re just logging the user ID and the updated email address.add_action
function to attach our custom functioncustom_user_update_action
to the'wp_update_user'
action. This means that whenever the ‘wp_update_user’ action is triggered, our custom function will be called.$user_id
to 123 (which would be the actual user ID) and create an array$updated_userdata
containing the updated user data. This could include changes to the user’s email, display name, or any other relevant fields.do_action
function to manually trigger the'wp_update_user'
action with the provided parameters. This simulates an update to the user’s information and will cause our custom function to be executed.Remember that in a real WordPress environment, these actions and hooks are automatically triggered by various processes within WordPress, and developers can use them to add their own custom functionality at specific points in the system’s execution.