plugins - How do I get the user ID of the user that was updated in WordPress?

admin2025-06-04  1

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?

Share Improve this question asked Jan 12, 2019 at 5:39 Biraj GautamBiraj Gautam 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749019164a315669.html

最新回复(0)