I want to run a custom function in my plugin that notifies me of the user that's email has been updated in wordpress backend. But i am not sure how do I get the user ID of that user, since this action hook add_action( 'update_user', 'when_update_user' );
requires me to pass an user ID to run when_update_user()
function when an administrator updates the user data. Does anyone have any idea regarding it?
I want to run a custom function in my plugin that notifies me of the user that's email has been updated in wordpress backend. But i am not sure how do I get the user ID of that user, since this action hook add_action( 'update_user', 'when_update_user' );
requires me to pass an user ID to run when_update_user()
function when an administrator updates the user data. Does anyone have any idea regarding it?
You're looking for profile_update
& user_register
.
user_register
is called after a user is created.
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
// Do stuff with $user_id
}
profile_update
is called after a user is updated.
add_action( 'profile_update', 'my_profile_update', 10, 2 );
function my_profile_update( $user_id, $old_user_data ) {
// Do stuff with $user_id
}