personal_options_update

Home » Hooks » personal_options_update

The personal_options_update hook is a WordPress action hook that is triggered when a user updates their personal options in their user profile. This hook is ideal for developers who want to add custom functionality to the user profile update process.

When the personal_options_update hook is triggered, it passes two parameters. The first parameter is the user ID of the user whose profile was updated, and the second parameter is the WP_User object that represents the updated user.

This hook can be used to perform a wide range of customization tasks, such as updating user meta data, sending notifications, or running custom actions. Developers can add their own custom functions to this hook by using the add_action() function.

Example Usage Code:

function my_custom_function( $user_id, $user ) {
    // Perform custom actions here
}
add_action( 'personal_options_update', 'my_custom_function', 10, 2 );

In the example code above, we define a custom function called my_custom_function that is triggered when the personal_options_update hook is fired. The function takes two parameters – $user_id and $user – which are passed by the hook. Our function can then perform any custom actions we want based on the updated user information. Finally, we use the add_action() function to attach our custom function to the hook.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.