Tutorials WordPress How to Limit Authors and Contributors to their Own Post in WordPress

How to Limit Authors and Contributors to their Own Post in WordPress

If you running a multi-author site, you will notice that all authors and contributors are able to see the posts from other users. Although they cannot edit or modify, you may not want them to see the posts which are under review or in the draft.

You can do this by installing third-party WordPress plugin such as View Own Post Media Only. But for this little job, I personally do not recommend to use any plugins.

This little code hack will help you to limit your authors and contributors to their own posts in WordPress admin. Copy and past the following code in you function.php file.

if (current_user_can('contributor') || current_user_can('author')){
	add_filter('parse_query', 'filter_my_own_posts_query' );
}

function filter_my_own_posts_query( $wp_query ) {
    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
      global $current_user;
      $wp_query->set( 'author', $current_user->id );
     }
}
Total
0
Shares
guest
0 Comments
Inline Feedbacks
View all comments
Previous Post

Best Online Payment Services Alternative to PayPal

Next Post
Wordpress Tutorials

How to Remove all WordPress Widgets in Admin Dashboard

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All
0
Would love your thoughts, please comment.x
()
x