• Resolved candell

    (@candell)


    Is it possible with Members to restrict back end editor access to specific users?

    For example, I have created a custom post type and populated with many posts. I want individual users to be responsible for a post(s) each, so when in the back end they view that custom post type page, all they see is the post they are responsible for?

    On the front end, everyone should be able to see everything, this is back end only.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • function limit_posts_current_author($query) {
    ????????global $pagenow;
    ????if( 'edit.php'!= $pagenow || !$query->is_admin )
    ????????return $query;
    ????if( !current_user_can('manage_options') ) {
    ???????global $user_ID;
    ???????$query->set('author', $user_ID);
    ????}
    ?????return $query;
    }
    add_filter('pre_get_posts','limit_posts_current_author');

    Try this function. Place in functions.php. It will show all posts to admins but for others it will limit query to author posts only.

    Let me know if it works.

    Thread Starter candell

    (@candell)

    That is awesome thank you. It worked great.

    Is it possible to ensure Admin and Editors can view all posts, whereas other roles can only see their own?

    • This reply was modified 1 year, 9 months ago by candell.

    In above function replace ‘manage_options’ to ‘edit_pages’

    This way editor will be able to see the all posts, while authors will see only their own.

    Is there a function I can add that will prevent people from adding new posts? For some reason when I select deny published posts in the settings it isn’t preventing authors from creating new posts. I only want to give them access to one page. I don’t want them to be able to publish posts. The above function helped me restrict them viewing posts but it still allows them to publish posts. Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Backend post access to specific user’ is closed to new replies.