0

I know when change primary role, set_user_role will be triggered, is there a similar hook for grant secondary roles?

  • What do you mean by "secondary" role? – Sally CJ Jan 30 '19 at 5:56
0

If whatever is adding the second role is going through standard methods: WP_User::add_role() then there's the add_user_role hook:

/**
 * Do something whenever a new role is added to an existing user
 * 
 * @param String $role
 * 
 * @return void
 */
function wpse327081_add_uer_role( $role ) {

    // Do Things

}
add_action( 'add_user_role', 'wpse327081_add_uer_role', 10 );
|improve this answer|||||

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.