如果添加第二个角色的内容是通过标准方法进行的:WP_User::add_role()
然后是add_user_role
挂钩:
/**
* 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 );