0

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?

2

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
}
  • thanks, i was using the wrong hook, this one helped. – Biraj Gautam Jan 12 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.