I need to load only the subscribers

$args = array('role' => 'Subscriber');
$subscribers = get_users($args);

but with this, it returns also the users that are subscriber AND other role (I need to delete my subscribers only, but keep subscribers with other role)

How do I get this users ?

  • You mean, you have users who have two or more roles like user1 having the roles subscriber and custom_role?
    – Sally CJ
    Commented Feb 1, 2021 at 16:03
  • 1
    Yes, user1 is subscriber and user2 is subscriber + manager, I need to get only user1
    – lucrece
    Commented Feb 1, 2021 at 16:14

1 Answer 1


One possible way is by using the role__not_in parameter like so which excludes all other roles except subscriber:

// Include only the following role(s):
$roles_in = array( 'subscriber' );

$roles_not_in = array_diff(
    array_keys( wp_roles()->get_names() ),

$args = array(
    'role__not_in' => $roles_not_in,

$subscribers = get_users( $args );

But of course, if you know the exact roles that should be excluded, then just do 'role__not_in' => array( 'role', 'role2', 'etc' ).

  • 1
    Thanks, I've ended up doing the second way
    – lucrece
    Commented Feb 2, 2021 at 9:01

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.