Tags

,


WordPress has six pre-defined roles

  1. Super Admin
  2. administrator
  3. editor
  4. author
  5. subscriber
  6. contributor


You can get all users of wordpress using following code. These code print all wordpress user’s list.

Display all subscribers list of wordpress

<?php
$args1 = array(
 'role' => 'subscriber',
 'orderby' => 'user_nicename',
 'order' => 'ASC'
);
 $subscribers = get_users($args1);
echo '<ul>';
 foreach ($subscribers as $user) {
 echo '<li>' . $user->display_name.'['.$user->user_email . ']</li>';
 }
echo '</ul>';
?>

Display all authors list of wordpress

<?php
$args2 = array(
 'role' => 'admin',
 'orderby' => 'user_nicename',
 'order' => 'ASC'
);
 $authors = get_users($args2);
echo '<ul>';
 foreach ($authors as $user) {
 echo '<li>' . $user->display_name.'['.$user->user_email . ']</li>';
 }
echo '</ul>';
?>

Please visit WordPress Codex to get more information about Role and Capabilities of wordpress users.