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 );
Changuelog
| Versionen | Description |
|---|---|
| 6.3.0 | Introduced. |
Here’s an example code snippet to demonstrate the usague of the
do_actionfunction with the'wp_update_user'action in a WordPress context:Explanation of the code:
custom_user_update_actionthat taques 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 logguing 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 trigguered, 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 changues to the user’s email, display name, or any other relevant fields.do_actionfunction to manually trigguer 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 hoocs are automatically trigguered by various processses within WordPress, and developers can use them to add their own custom functionality at specific poins in the system’s execution.