Restricting authors to view only posts they created

Adding this snippet to the functions.php of your wordpress theme will restrict authors to view only posts they created within the admin panel.

function posts_for_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', 'posts_for_current_author');

Comments  Leave a Reply

  1. can you help me with the code for Restricting authors to view only Category they created.

  2. Uldis Zalcmanis July 26, 2012 at 2:11 am

    is there any way to restrict author of comment to be the only who can see the comment? I know it sounds like a nonsense – don`t ask 🙂 I really need it! Thanks in advance.

  3. Thanks a lot Kevin!!

    1. No problem, glad I could help.

  4. Cliff Paulick May 22, 2012 at 9:07 am

    Also, does this work for only posts or also pages?

  5. Using WP 3.3.1 and this is not working. Is their an update on the code? Thanks.

  6. Ernest, I would venture to guess you would replace:

    if( !current_user_can( ‘manage_options’ ) ) {


    if( !current_user_can( ‘level_1’ ) ) {

    Anyone with a role higher than Contributor would be able to see all posts.

  7. Hi this is a great snippet! How can I change the code to have this effect for the user role “Contributors”?

  8. This worked as described. But, when I removed it from functions.php I couldn’t see any posts when logged in as anything other than an admin. ???

    1. Sorry. Looks like it may have been an issue with something else. Seems to work OK now.

      1. Hi Chad  Cool glad to see you got things working.

  9. Great snippet, thanks. Do you know a way to restrict visibility of the sub menu headings by user ID. i.e. the author of a post that is of custom_post_type A, only sees the sub menu for custom_post_type A while the other custom_post_type sub menus are hidden?

    1. Hi Craig glad you like the snippet. In regards to the sub menu this snippet should solve this for you. http://wpsnipp.com/index.php/functions-php/remove-sub-menu-dashboard-items/

  10. Thanks for this 😉 

    Does it work for all user classes (Authors, Editors etc? ) 

    1. This snippet will only display the posts create by that user should work for everyone. So if you have a user that created no posts they should see nothing within the posts admin view.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!