To fetch users from a specific role, you can use the role
parameter of the get_users
function. Each role has a specific ID; for WordPress’ native roles, these are administrator
, editor
, author
, contributor
and subscriber
. In your case, you would want to fetch only subscriber
users:
$allUsers = get_users( array(
'orderby' => 'post_count',
'order' => 'DESC',
'role' => 'subscriber'
) );
Related Posts:
- How do I programmatically set default role for new users?
- How to programmatically add a user to a role?
- Order users by custom user meta
- List total number of users that are authors
- How do I properly format the user_role array?
- Get (echo) all role names assigned to user
- Can’t manage to make translate_user_role() work
- exclude roles from overview
- get approved users only ( ultimate member plugin )
- Query users which have same dynamically generated roles as the current user
- Menu page with list of users
- How to get a users list by who created them?
- List of users with email and role
- Can someone help me out? Why isn’t this working?
- Getting a List of Currently Available Roles on a WordPress Site?
- Editor can create any new user except administrator
- How to get role of user
- Check if user is admin by user ID
- How to update role capabilities
- create users to site with specific language
- How to loop through each user id?
- Ordering users of a specific role by last name
- How to stop a user from updating the post date
- how to add custom user capabilities using add_user_meta or something else?
- User roles – enable custom posts disable posts
- WordPress edit_user_profile_update update secondary role
- How to get the Role Name of the current user? (WordPress)
- How to get all users with Author role capabilities?
- set_role has no effect
- Add Role inherits?
- similar to Editor can create any new user except administrator
- How to check if a role has a specific capability
- Expire a user’s secondary role after X days from it being allocated
- Can a user with admin role get ‘Sorry, you are not allowed to move this item to the Trash’ error when trashing a post?
- Making shortcode of filtered number of comments by user role
- How to stop contributors editing post type but allowing them to edit a custom post type?
- Allow Block Editing By User Role
- How do I list in the backend all users that were assigned to a custom role?
- WordPress missing user roles on local dev machine. Live site works fine
- How to add local users to wordpress without email password?
- Programmatically allow a non-author to edit a post based custom meta field
- Register rest field for specific user
- Are User Levels Still Currently Used?
- Error: How to allow the “contributor” to upload media in wordpress
- Pending status by default for a specific role
- Getting a role based on a localized role name
- How do I restrict user access to plugins?
- List all private pages user has access rights to read
- Is possible to allow user to login with different role?
- Undo User Role Name Change
- add_role user capability not working
- Limit a user to have access to only specified pages?
- How can I promote a user to a network administrator?
- How do I let contributors edit their posts after being approved once?
- read_private_pages capability not working for new role
- Restrict custom post content to specific user
- How can I programattically hide all admin notices for everyone except admin users
- Foreach loop inside an array_merge
- How to exclude subscriber from the list in wordpress
- how to make a custom field readonly or disabled by user role?
- Fix ‘Add Role’ Option not there in wordpress 5.2.2
- Create sub-administrator role that can do everything except use or see the code editor
- display user roles in comment form
- Plugin permissions for Editor role
- How can I change my assigned user role in WordPress 3.5.1?
- Role based permission edit for plugins
- Is it proper to build a site supporting blog visitors in WordPress?
- Removing capabilities from cloned admin role
- Setting an expiration date for wordpress roles
- Could we know who published a post on WordPress?
- Auto Change WordPress Roles
- How to check if a user is in a specific role?
- Custom Plugin – Blacklist/Whitelist domain email and change user role – Suggestions
- Block access to plugins.php for custom role
- How to make WP page accessile only to specific user roles
- Remove add post for user role
- WordPress – Limit custom/specific user role to only have access to edit the contents of an Advanced Custom Fields Pro Options Page
- TCPDF only exports .pdf when user is administrator
- wp_get_current_user Not working
- How to allow suscriber to access specific pages in dashboard?
- Enable plugins for a specific user role
- Switch role on submit button
- Multiple user role on registration
- Trying to get new role to have edit permissions for custom content type
- Why are all roles assigned to a user when using wp_insert_user()?
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- Front end login and page restriction
- Get author meta of all writers
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- Grant access to admin menu?
- i need to let a user to add a role from a frontend form
- I want this code to work only for Authors AND Contributors
- Disable Woocommerce checkout based on user role [closed]
- Remove_role not working, gives “Call to undefined method stdClass::remove_role()”
- Adding a new role with administrator’s capabilities
- How to lock users account until approvation
- WordPress users roles wp-admin
- How to create a User Role and give permission to only use Web Stories plugin?
- User roles empty
- How to add custom user role into wordpress