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?
- How to Get All Posts with any post status?
- posts_per_page no limit
- How can i get count from query post
- query_post by title?
- user_login vs. user_nicename
- Why query_posts() isn’t marked as deprecated?
- Alternative to query_posts for main loop? [duplicate]
- Adding fields to the “Add New User” screen in the dashboard
- how to query posts by category and tag?
- Difference between update_user_meta and update_user_option
- How to filter users on admin users page by custom meta field?
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- get_user_meta() doesn’t include user email?
- Order by meta value or date?
- How do I query by post format in WordPress 3.1
- Display posts of the last 7 days
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Filtering posts by post meta data
- 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?
- Check if user is admin by user ID
- Query posts by custom taxonomy ID
- Display/query post formats
- Return all users with a specific meta key
- How to query post by user role?
- How to return results of a get_posts() in explicitly defined order
- Where the Nickname is being used in WordPress
- How to display custom user meta from registration in backend?
- Allowing an email as the username?
- Help to condense/optimize some working code
- Grouping users under parent user
- get_users is expecting unserialized meta_value
- How to set posts per page using WP_Query()
- query_posts exclude a meta key
- How do I create a random post that will last for a day
- Ensuring sticky posts are retrieved first (without using two queries)?
- Determine if more posts are available than was asked for in `query_posts()`?
- How to get users by a custom field / by user meta data?
- Modify main WordPress loop with a parse_query filter
- How to create a template for a custom URI associated with the user
- How to order users alphabetically by their last name?
- Getting all user metadata from user
- query_posts() in function makes global $wp_query out of sync?
- Limiting query_posts to 1, regardless of sticky post?
- How to make “sticky” pages (and query by them)
- How do you add a custom option to user data?
- Extending WP_User class and using this sub-class during the whole lifecycle
- Query posts: how to exclude results if post is in multiple categories
- Wp_User_Query not sorting by meta key
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- Problem with ‘post__not_in’
- Add a button to users.php
- How to order posts by descending comment count on taxonomy page?
- How we can get the user id by its display_name
- WP_User_Query with combined meta query – not working?
- How to use hyperdb to separate and share a user dataset between wordpress installs?
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- Show Biographical Info while creating new user
- Sort posts alphabetically by custom field value, insert divider between different letters
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- WP 5.8 “Query Loop” block: where to place custom query?
- Sort X categories by last update and show image
- Custom Post Type “Event”: chronological list of recurring events
- using post__in allow duplicate post id
- Pagination on archive.php page
- include user profiles in search results?
- How to add follow functionality to multi-author wordpress site?
- Search multiple meta keys at once
- How may I filter get_users() similarly to pre_get_posts?
- WordPress Custom Query
- Best way to load page content in Fancybox popup?
- Where to Store Custom User Fields
- How should I intercept the main query and inject custom join / order by / group by criteria
- advice on creating a ‘related posts’ query like the one used on stackexchange
- order post my meta value m/d/y format with year as included value
- Order by meta value, pro first, then free
- Having trouble generating pagination links on custom query
- Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that
- How to create an attachments archive with working pagination?
- _wp_page_template to dynamically use template
- Querying Email Addresses for a List of Users with Same Last Name?
- Display sortable User meta column in admin panel user’s page
- Using dynamic conditions in ‘posts_where’ filter
- Show User Their Password
- User profile custom field
- Help altering a query to exclude all but standard post format
- Showing user ID on user main page from screen options
- Front end user meta options for users
- Schedule Sticky Posts
- Use union/intersection query_posts variables in uri request parameter form?
- query_posts doesn’t order by title
- How to limit search to first letter of title?
- query_posts and pagination, still stuck after much research
- Query posts by taxonomy term name
- Sorting problem with ‘query_posts’ funcion in wordpress. Sort by custom field not working