3

I am using WP3 and want to starting adding users (many users to a single blog) but when I give a new user an account, they can see all the posts in the admin including scheduled, drafts, pending review etc. I either need the users to ONLY view their own posts or only view their own published posts (but not scheduled, drafts, etc). The admin should be able to see everything.

Here is a link I found on this issue with a code but the code is not working in my functions.php

http://wordpress.org/support/topic/show-only-authors-posts-in-admin-panel-instead-of-all-posts

5

Put this into your functions.php file in your theme folder...

function query_set_only_author( $wp_query ) {
    global $current_user;
    if ( is_admin() && !current_user_can('manage_options') ) {
        $wp_query->set( 'author', $current_user->ID );
    }
}
add_action('pre_get_posts', 'query_set_only_author' );
  • Great snippet, btw how can this be done only for custom post type? – Mamaduka Jul 1 '11 at 14:03
1

Have a look here for a more complete solution (fixes the post count on the filter bar): Help to condense/optimize some working code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.