The User Query Class
There’s a class to query users. This makes a) more easy and b) more future proof as mostly the internals will change, but not the way you access it.
$the_authors = new WP_User_Query( array(
'role' => 'author'
) );
foreach ( $the_authors as $author )
{
// Show what we got:
var_dump( $author );
echo '<br />';
// Access parts of the author/user object(!)
// echo $author->first_name;
}
Role vs. User Level
User level itself is deprecated since (I don’t know how many, but really many) versions. You shouldn’t use that. The idea behind it is that user levels are a hirachical way of organizing restrictions, while roles are not. In theory you can give a user more than one role to reflect the restrictions and possiblities she/he has in your system.
Related Posts:
- List users with the most total posts view
- Author List page: Exclude based on last post date
- Show individual author rank from query of cumulative post view count for all authors
- Query posts based on the meta key values of logged-in users?
- query_post by title?
- How to filter users on admin users page by custom meta field?
- Automatically delete inactive users after 2 months
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- How to get users by a custom field / by user meta data?
- Modify main WordPress loop with a parse_query filter
- How to order users alphabetically by their last name?
- Wp_User_Query not sorting by meta key
- Problem with ‘post__not_in’
- Add a button to users.php
- How to use hyperdb to separate and share a user dataset between wordpress installs?
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- using post__in allow duplicate post id
- include user profiles in search results?
- Show User Their Password
- User profile custom field
- Front end user meta options for users
- How to sort by meta value?
- pagination in author.php template returns 404 error
- How can I sort get_users() by any value (last_name, user defined fields and more)
- Extend the wp_users table
- query recent posts from several categories
- Example Query Posts Showing the Latest Post with the Featured Image
- Drop down list in user profile page
- Dynamically excluding current page id
- Query wp_usermeta alongside wp_users
- Searchable meta value in user.php
- How to order results by date and meta key?
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- posts_per_page => 1 shows 2 posts
- Custom posts per page does not work with pagination
- Uncheck the box “Send User Notification” by default on new-user.php
- Add user data to table when user is created?
- posts_per_page override by default settings
- How to paginate posts correctly that belong to a particular category and are random ordered
- Use wp_update_user to update custom column in wp_users table
- How to filter query to display posts from parent category only?
- Display random post on a page with post permalink in URL
- Display users in order by an “order” custom meta field
- WordPress pagination with get_posts?
- Using ajax with paging and a custom sub-query
- Updating wp_user_level on user update
- ACF Query meta_values don’t work with ‘offset’
- Adding custom class to get_avatar() image doesn&https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/#39;t work
- How can I attach a user to another user with user meta
- How to retrieve an array of post IDs by a particular value stored in a custom meta’s array
- define orderby URL with meta_key=post_views_count
- Query_posts and attachments
- Custom loops, sticky posts, and pagination nightmare
- Querying posts only if the current page is not paged?
- How to build a fool proof AdSense revenue sharing model?
- how to store wordpress loop in array?
- meta_query check for meta value in key which holds an array of values
- Exclude posts by post meta value
- Single-page wordpress theme navigation
- meta tag placement for google verification
- When to use WordPress loop or Foreach loop?
- Can’t get pagination to work for sticky posts only
- show x number of posts from y category on homepage
- Users table missing from Database [closed]
- check for duplicate user meta data before updating
- Send admin new order email to logged in user as well
- How would I be able to use a font awesome icon as a user’s avatar?
- Frontend form with multiple posts
- Front-End User Profile
- Way to cache a query for 24 hrs
- Can user meta be shown or hidden depending on user logged in status?
- wp_insert_user not creating account correctly when ID is manually set
- Displaying and Querying Posts with Featured image
- User Meta stuff
- Meta query stopped working
- Sticky posts don’t show up first in custom loop
- Want Page Descendants when using query_posts post_parent or child_of
- grab neighboring content in a query
- Querying a query
- How do I query based on the modified date?
- Is there any way of only retrieving posts with one or more thumbs up (GD star rating plugin)?
- How do I update user email from frontend input field?
- How can i add user display name drop down menu in frontend?
- How to prevent multiple user accounts with the same meta field?
- How to get all multi-select user meta values and add them to an array?
- Add another role to a user when they click a button?
- Storing data to database and user registration
- update multiple user meta field based on another meta field
- How to get user meta value in wordpress
- wp_query by last month + sort posts
- Creating Custom user type just like custom post
- query_posts not working after wordpress 3.7 update
- Is that the query_posts() the real criminal here?
- Query specific posts from parent by slug rather ID
- query_posts and sub pages?
- How to refine WP-Query with further criteria
- prevent display duplicate titles on main page
- Lots of SQL queries
- Extend user search in the users.php page to allow for searching by role and excluding specified email domains from the “users search” input box
- How can I list users by date in an array in meta_value?