How-To Wordpress

How to list users by their role WordPress?

If you are the only person controlling your whole website, you have probably never had to think about WordPress users and their roles. However, if you ever want to give other people access to your WordPress website, WordPress user roles are essential for managing what actions the various users at your site are allowed to take.

WordPress user roles determine what actions each user at your site is authorized to perform. These actions are called capabilities. In this article, we are going to show how to list WordPress users by their user role.

WordPress has some pre-defined user roles :

  1. Super Admin
  2. Administrator
  3. Editor
  4. Author
  5. Subscriber
  6. Contributor

Here is the code to display the list of users, by their Specific Roles. We can also delete these default User Roles if not required for the website.

In the below array we have given the user role as “subscriber” so it will make the list of users who is having the role “Subscriber” with their E-mail.

$args = array(
'role' => 'Subscriber',
'orderby' => 'user_nicename',
'order' => 'ASC'
$users = get_users( $args );

echo '<ul>';
foreach ( $users as $user ) {
echo '<li>' . esc_html( $user->display_name ) . '[' . esc_html( $user->user_email ) . ']</li>';
echo '</ul>';

Happy Coding 🙂

About the author


A coder who is trying to solve some problems via "Procoders", Software Engineer By Profession, WEB Enthusiast, Hobby Blogger. I love to share Tech Ideas and like to learn and explore new things and Technologies.

Add Comment

Click here to post a comment