Get multiple roles with get_users

Fastforward to WordPress 4.4 – it will support the role__in attribute!

It looks like WordPress 4.4 is our lucky version number, because it will support both the role__in and role__not_in attributes of the WP_User_Query class.

So to include the subscriber, contributor and author roles, we can simply use:

$users = get_users( [ 'role__in' => [ 'subscriber', 'subscriber', 'author' ] ] );

Check out the ticket #22212 for the whole story!

Leave a Comment