0

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

1
  • What do you mean by "secondary" role?
    – Sally CJ
    Commented Jan 30, 2019 at 5:56

1 Answer 1

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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