一种可能的方法是使用role__not_in
类似so的参数,它排除了除subscriber
:
// Include only the following role(s):
$roles_in = array( \'subscriber\' );
$roles_not_in = array_diff(
array_keys( wp_roles()->get_names() ),
$roles_in
);
$args = array(
\'role__not_in\' => $roles_not_in,
);
$subscribers = get_users( $args );
当然,如果你知道应该排除哪些角色,那就这么做吧
\'role__not_in\' => array( \'role\', \'role2\', \'etc\' )
.