You are viewing an old revision of this post, from March 17, 2014 @ 13:00:32. See below for differences between this version and the current revision.

How To Limit The WordPress Posts Screen To Only Show Authors Their Own Posts

When working on a multi-author WordPress blog, the post listing screen can get a little bit crowded. Sometimes you have to hunt through many posts that are not your own before locating a draft you’ve been working on. Here’s a quick way that you can change the posts page to show only the author’s own posts. I found this handy tip over at WP Snippets and have updated it and made into a little plugin. Essentially, the code below checks to see if a user has admin capabilities. If the user is not an admin, he will only see his own posts listed on the posts edit screen, making it easier for him to locate his own posts. The total number of posts published, drafts and pending posts will remain the same, despite the user only being able to see his own. [php] <pre id="fvch-code-0"><?php /* Plugin Name: Simplify Post Edit List Description: Show only the author's posts in the edit list Version: 0.1 License: GPL Author: Sarah Gooding Author URI: http://untame.net */ function mypo_parse_query_useronly( $wp_query ) { if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { if ( !current_user_can( 'update_core' ) ) { global $current_user; $wp_query->set( 'author', $current_user->id ); } } } add_filter('parse_query', 'mypo_parse_query_useronly' ); ?></pre> [/php] Open a blank text file. Add the code above to it and save it as a php file. Name it anything you want. Then upload the file to your /wp-content/plugins directory. You can now activate the plugin in your WordPress dashboard. Log in as a user other than admin. Any user who hasn’t written any posts won’t be able to see any in the list. This little plugin is very useful if you want to keep multiple authors’ posts private from each other while they are still in draft stage or if you just want to clean up the posts screen to keep things simple in the dashboard.

Revisions

Revision Differences

March 17, 2014 @ 13:00:32Current Revision
Content
Unchanged: When working on a multi-author WordPress blog, the post listing screen can get a little bit crowded. Sometimes you have to hunt through many posts that are not your own before locating a draft you’ve been working on.Unchanged: When working on a multi-author WordPress blog, the post listing screen can get a little bit crowded. Sometimes you have to hunt through many posts that are not your own before locating a draft you’ve been working on.
Unchanged: Here’s a quick way that you can change the posts page to show only the author’s own posts. I found this handy tip over at <a href="http:// wp-snippets.com/only-show- the-authors-posts- in-the-edit-list/" target="_blank">WP Snippets</a> and have updated it and made into a little plugin.Unchanged: Here’s a quick way that you can change the posts page to show only the author’s own posts. I found this handy tip over at <a href="http:// wp-snippets.com/only-show- the-authors-posts- in-the-edit-list/" target="_blank">WP Snippets</a> and have updated it and made into a little plugin.
Unchanged: Essentially, the code below checks to see if a user has admin <a href="http:// codex.wordpress.org/Roles_ and_Capabilities#Capabilities" target="_blank" >capabilities</a>. If the user is not an admin, he will only see his own posts listed on the posts edit screen, making it easier for him to locate his own posts. The total number of posts published, drafts and pending posts will remain the same, despite the user only being able to see his own.Unchanged: Essentially, the code below checks to see if a user has admin <a href="http:// codex.wordpress.org/Roles_ and_Capabilities#Capabilities" target="_blank" >capabilities</a>. If the user is not an admin, he will only see his own posts listed on the posts edit screen, making it easier for him to locate his own posts. The total number of posts published, drafts and pending posts will remain the same, despite the user only being able to see his own.
Unchanged: [php]Unchanged: [php]
Unchanged: &lt;pre id=&quot;fvch- code-0&quot;&gt;&lt;?phpUnchanged: &lt;pre id=&quot;fvch- code-0&quot;&gt;&lt;?php
Unchanged: /*Unchanged: /*
Unchanged: Plugin Name: Simplify Post Edit ListUnchanged: Plugin Name: Simplify Post Edit List
Unchanged: Description: Show only the author's posts in the edit listUnchanged: Description: Show only the author's posts in the edit list
Unchanged: Version: 0.1Unchanged: Version: 0.1
Unchanged: License: GPLUnchanged: License: GPL
Unchanged: Author: Sarah GoodingUnchanged: Author: Sarah Gooding
Unchanged: Author URI: http://untame.netUnchanged: Author URI: http://untame.net
Unchanged: */Unchanged: */
Unchanged: function mypo_parse_query_useronly( $wp_query ) {Unchanged: function mypo_parse_query_useronly( $wp_query ) {
Unchanged: if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {Unchanged: if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
Unchanged: if ( !current_user_can( 'update_core' ) ) {Unchanged: if ( !current_user_can( 'update_core' ) ) {
Unchanged: global $current_user;Unchanged: global $current_user;
Unchanged: $wp_query-&gt;set( 'author', $current_user-&gt;id );Unchanged: $wp_query-&gt;set( 'author', $current_user-&gt;id );
Unchanged: }Unchanged: }
Unchanged: }Unchanged: }
Unchanged: }Unchanged: }
Unchanged: add_filter('parse_query', 'mypo_parse_query_useronly' );Unchanged: add_filter('parse_query', 'mypo_parse_query_useronly' );
Unchanged: ?&gt;&lt;/pre&gt;Unchanged: ?&gt;&lt;/pre&gt;
Deleted: [/php]</pre> Added: [/php]
Unchanged: Open a blank text file. Add the code above to it and save it as a php file. Name it anything you want. Then upload the file to your /wp-content/plugins directory. You can now activate the plugin in your WordPress dashboard.Unchanged: Open a blank text file. Add the code above to it and save it as a php file. Name it anything you want. Then upload the file to your /wp-content/plugins directory. You can now activate the plugin in your WordPress dashboard.
Unchanged: Log in as a user other than admin. Any user who hasn’t written any posts won’t be able to see any in the list.Unchanged: Log in as a user other than admin. Any user who hasn’t written any posts won’t be able to see any in the list.
Unchanged: This little plugin is very useful if you want to keep multiple authors’ posts private from each other while they are still in draft stage or if you just want to clean up the posts screen to keep things simple in the dashboard.Unchanged: This little plugin is very useful if you want to keep multiple authors’ posts private from each other while they are still in draft stage or if you just want to clean up the posts screen to keep things simple in the dashboard.

Note: Spaces may be added to comparison text to allow better line wrapping.

No comments yet.

Leave a Reply