Fires after the user has been updated and emails have been sent.
Parameters
$user_idint- The ID of the user that was just updated.
$userdataarray- The array of user data that was updated.
$userdata_rawarray- 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_actionfunction with the'wp_update_user'action in a WordPress context:Explanation of the code:
custom_user_update_actionthat 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_actionfunction to attach our custom functioncustom_user_update_actionto the'wp_update_user'action. This means that whenever the ‘wp_update_user’ action is triggered, our custom function will be called.$user_idto 123 (which would be the actual user ID) and create an array$updated_userdatacontaining the updated user data. This could include changes to the user’s email, display name, or any other relevant fields.do_actionfunction 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.