简体   繁体   中英

get_posts returns posts by current user only

I have a wordpress blog that has many users roles. When logged in as admin get_posts seems to return all the posts but when logged in as retailer ( role I created ) I only get the posts that the logged in user created

$argArray = array('post_type' => $type, 'post_status' => 'publish', 'orderby' => 'title','numberposts' => -1 );
 $posts = get_posts($argArray);

This code when logged in as admin returns all the posts in the site but when logged in as retailer return only the posts that the user authored.

BTW $type is a post_type

There is no mention of this in the documents or anywhere. is it something I am doing wrong or is it the way this is supposed to be?

Thanks in advance!!

UPDATED

AS I am looking over this it seems that worpdress query does add author argument in the wordpress query.I did new WP_Query() and checked.

This is the part that I want to remove wp_posts.post_author = 347 This is not present in the query made by admin. I have seen remove_query_arg in wordpree query but not sure when and how to use it and if it can be used to remove this argument in the query at all.

Help!!

Try to make sure, you assigned appropriate roles and capabilites for your role retailer .

get_posts uses WP_Query , where those restrictions are verified.

Eventually, take look at get_pages , as I checked it, in the query there in no such a verification, if I am not mistaken.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM