WordPress.org

Support

Support » Plugins and Hacks » Role Scoper » [Resolved] [Plugin: Role Scoper] query_posts not working because of Role Scoper

[Resolved] [Plugin: Role Scoper] query_posts not working because of Role Scoper

  • I am using query_post to get few posts of some author, the code is like this,

    query_posts(array(
            'author' => $author_id,
            'paged' => $paged,
            'posts_per_page' => $posts_per_page,
            'post_status' => 'publish',
        ));

    The function having this query is registered as follows:

    add_action('wp_ajax_infinite_scroll', 'wp_infinitepaginate');
    add_action('wp_ajax_nopriv_infinite_scroll', 'wp_infinitepaginate');

    For admin this query works properly. But for not logged in users, php function having this query gets executed but the query returns empty array.

    If I disable ‘Role Scoper’ the query_posts works for not logged in users also. How can I fix this problem

    Query function : http://pastebin.com/eiVKLf5t
    Ajax Call : http://pastebin.com/q2VjFBhK

    http://wordpress.org/extend/plugins/role-scoper/

Viewing 3 replies - 1 through 3 (of 3 total)
  • same issue here
    The output of query if rolescoper is active is:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = ‘consejo’ AND (( ( ( ( ( 1=2 ) ) ) ) AND wp_posts.post_status = ‘publish’ )) ORDER BY wp_posts.post_date DESC LIMIT 0, 9

    The condition 1=2 makes that no post are return…

    Plugin Author Kevin Behrens

    @kevinb

    Since you are using Ajax, there is no way for Role Scoper to “know” that the result set should be all readable posts or all editable posts. Of course I have to default to all editable posts.

    Sometime determining the appropriate post type is also problematic. You can change your call to:

    query_posts(array(
            'author' => $author_id,
            'paged' => $paged,
            'posts_per_page' => $posts_per_page,
            'post_status' => 'publish',
            'post_type' => 'your_post_type',
            'required_operation' => 'read',
        ));
    Plugin Author Kevin Behrens

    @kevinb

    Actually, the required_operation arg will not be effective until Role Scoper 1.3.62.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: Role Scoper] query_posts not working because of Role Scoper’ is closed to new replies.
Skip to toolbar