I am facing a strange issue. Some of my user roles are changing automatically. I searched in the whole project and cannot find the location from where user roles are changing. So I added the following code in my functions.php
add_action( 'set_user_role', function( $user_id, $role, $old_roles ){
mail('[email protected]','User role is changed from admin',
'This mail is sending from set_user_role hook in functions line 2450. The user id is '.$user_id.
'The loggedin user is '.get_current_user_id()
);
}, 10, 3 );
I am getting the emails with changed userids. but the currently logged in user is showing as 0. So I assume the function is not calling from admin and the following function is running somewhere in my function.
$user->add_role( 'userrole' );
But I cannot find the function $user->add_role();
in my project. Is this hook is called in any other cases?
Please help me to solve this.
I am facing a strange issue. Some of my user roles are changing automatically. I searched in the whole project and cannot find the location from where user roles are changing. So I added the following code in my functions.php
add_action( 'set_user_role', function( $user_id, $role, $old_roles ){
mail('[email protected]','User role is changed from admin',
'This mail is sending from set_user_role hook in functions line 2450. The user id is '.$user_id.
'The loggedin user is '.get_current_user_id()
);
}, 10, 3 );
I am getting the emails with changed userids. but the currently logged in user is showing as 0. So I assume the function is not calling from admin and the following function is running somewhere in my function.
$user->add_role( 'userrole' );
But I cannot find the function $user->add_role();
in my project. Is this hook is called in any other cases?
Please help me to solve this.
1 Answer
Reset to default 2Good catch with the action, catching the instance.
You might be able to add a debug_backtrace() to trace it back to the calling functions, and their calling functions, to see how you actually get there.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745437984a4627697.html
评论列表(0条)