How to get all users with Author role capabilities?

Today, We want to share with you get all users in wordpress.In this post we will show you wordpress show all users on one page, hear for Role and Capabilities of word press users. we will give you demo and example for implement.In this post, we will learn about How to get current user Information in word press? with an example.

Read Also:  How to Get current User details in Wordpress woocommerce? | WP_User() | wp_get_current_user() | get_user_by() | get_userdata()

Get Users List by Role in WordPress

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 simple PHP Source code. These simple source code print all wordpress user’s list.

Display all subscribers list of wordpress

<?php
$params_val = array(
 'role' => 'subscriber',
 'orderby' => 'user_nicename',
 'order' => 'ASC'
);

$subscribers = get_users($params_val);

echo '<ul>';
	 foreach ($subscribers as $member) {
	 	echo '<li>' . $member->display_name.'['.$member->user_email . ']</li>';
	 }
echo '</ul>';
?>

Display all authors list of wordpress

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

I hope you get an idea about get users by role wordpress.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  Validating Woocommerce webhook using HMAC in PHP

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  PHP wc_get_product Examples
  2. Read Also:  Increase WordPress Memory Limit using PHP
  3. Read Also:  PHP Set custom headers using cURL Example
  4. Read Also:  WooCommerce Get Product Prices
  5. Read Also:  How to Find The Total Number of Products in WP REST API v3?
  6. Read Also:  How to create custom PHP page-Template using WordPress
  7. Read Also:  List of all WordPress WooCommerce hooks
  8. Read Also:  WordPress AJAX - Wordpress jQuery AJAX POST Request
  9. Read Also:  How to create custom PHP page-Template using WordPress
  10. Read Also:  PHP wc_get_product Examples
CLOSEX