If I’m understanding this correctly something along these lines should work.
$authors = array( 1, 2, 3 ); // privileged users array
$signed_in_user = wp_get_current_user(); // get current user
// check if singed in user is in authors array
if ( in_array( $signed_in_user->ID, $authors ) ) {
$query = array(
'posts_per_page' = -1,
'author__in' = $authors
);
}
else {
// alternate query for other users
}
$posts = new WP_Query( $query );
Related Posts:
- author.php with ACF and CPTs
- Query to return maximum of one post per author
- Show only oldest post by author
- Function to check if author has posted within the last x days
- Show one post per author and limit query to 8 posts
- Pagination 404 errors for author posts query on author.php
- Only display authors who have posts
- Get List of all the Authors
- How can I display list of all posts from a specific author, with publish dates in the future, on an author archive page (author.php)?
- Get authors by term id or slug
- Dynamic User Id
- Custom Query by Author field and meta
- slow WP_Query for non-admin user
- WP_Query (list) posts according to author’s custom field
- Exclude some authors from query
- Get author if post has multiple authors
- All posts returned when author of 0 is queried
- Posts in loop all show the same author when there are many authors
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Display if author page is author page of current user
- Exclude authors IDs from WP_Query
- WP_Query author parameter not working
- query post by author gender
- How can i show pagenavi in my author.php?
- wp query to use both author id and meta_query
- Counting instances of words in the results of a post query
- Query posts by post type, author and post meta
- Get authors list and sort them by recent posts
- query all posts published by certain user id
- Reduce or prevent calling of update_meta_cache
- Order wp_query by calculated field
- new WP_Query() – what is the earliest valid hook?
- Extending WP_Query — Optimise SQL query
- WP_query and pagination?
- Select posts with any post_type from database?
- Better to make new wp_query or only modify main query each time?
- How to display images in related posts?
- What is the difference in a query when using a fieldname as a meta key vs orderby field?
- Get all post IDs from current WP_Query – not just currently visible
- How to Modify Taxonomy Archive Page with Search Parameter?
- $wpdb->insert inserting two rows in database
- WP-Admin edit.php & post.php slowdown after import of 10k users
- WP Query for variable taxonomies
- WP_query Date Range results not matching loop
- $wpdb select date range of posts
- Meta Query relation “AND” not working
- Return only post(s) which have post_excerpt
- Add quicklink to in the Admin posts page where I can query by a meta_key
- Exclude an array
- Front page with registered query params in URL shows blog archive instead of front page
- Cutom wp_query for geolocation search, pagination not working
- Tax query AND/OR meta query [duplicate]
- Warning: Invalid argument supplied for foreach(). when creating a WP_query
- Help ordering Post loop by two meta values
- Display most popular in the past two days
- How to sort a custom wordpress query by combination of meta values?
- get_post_meta in WP_Query
- How to alter local query, not main query [duplicate]
- Order by most used tag
- WP_Query results stored in variables
- infinite loop in wp_query using simple query
- How to display the number of posts in a category using WP Query
- wp query for popular post with simple field
- Parent and child categories
- Set post number to single posts
- Specific html within wordpress loop
- Shortcode Not Working in Slider When Added To Post Title
- Multiple pagename WP Query
- How does WP generate the default $query in WP_Query based on the URL?
- Grabbing taxonomy terms and inserting them into an array
- custom page with post content using read more
- Offset WP_Query by negative 1
- WP_Query orderby random do not repeat infinite scroll – one loop
- how to put thumbnail below category’s title?
- Woocommerce Shortcode which displays a table with product data
- JOIN filter doesn’t work in WP_Query in wp-ajax calls
- Why when I using infinity scroll the one post loads over and over?
- get_posts query is taking about 40 seconds to execute
- Customize the Sorting Dropdown in WooCommerce use another list or more page
- WP_Query by MAX post_id?
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- WP Query with meta queries
- Query post by Category and custom file (ACF)
- Regarding a custom loop and output HTML tags
- Filtering ‘Featured’ posts from a batch of category IDs
- My entry results are not consistently alphabetized
- Speed up WP_query with meta comparing dates
- Meta Query if Values Don’t Exist
- Letting wordpress decide what template and page to use based on condition
- How to show all the associated posts with specific date of data metabox?
- How to order by datediff in WP loop?
- Custom query for tag and custom tag from 2 post type
- wpdb get_results() returns only 2 rows
- Search Functionality broken by the wp 4.2 update
- Issue attempting a wp_query_posts with tags
- Custom query to show posts
- New WordPress WP Query using posts from certain categories
- WP query based on two meta queries
- WordPress website links redirect to homepage
- Is there another way to retrieve a post_id from post_meta other than a SQL query?