The code snippet in this article shows you how to get all WordPress users with a certain role, and the options available to further filter results.
Limiting returned users to specific arguments is easy with the WordPress get_users function. The following code snippets show you how.
To get all WordPress users with a specific role you'll want to pass in the 'role' argument to the get_users function like so:
get_users( 'role' => 'administrator')
WordPress has six default roles that are pre-defined: super admin, administrator, editor, author, contributor and subscriber. You can replace these in the role argument above, or if you have a custom role that you have registered you could also use that.
Here's a full list of arguments for the get_users function if you want to add some additional parameters to filter or order the data: