admin管理员组文章数量:1130349
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?
1 Answer
Reset to default 2You'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
}
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?
1 Answer
Reset to default 2You'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
}
本文标签: pluginsHow do I get the user ID of the user that was updated in WordPress
版权声明:本文标题:plugins - How do I get the user ID of the user that was updated in WordPress? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749019139a2304112.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论