I know when change primary role, set_user_role will be triggered, is there a similar hook for grant secondary roles?
1 Answer
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 );