Restrict authors to display only their posts on WordPress

Sometimes it can be very useful to make sure that on the wordpress board authors see only and exclusively their articles. Do this only if you are able to make a backup, to restore it without problems and if you know what you are doing. In the function.php file of your theme you have to add the following code (of course, the display will not be restricted for administrators):

function posts_for_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'edit_others_posts' ) ) {
global $user_ID;
$query->set('author', $user_ID );
return $query;
add_filter('pre_get_posts', 'posts_for_current_author');

It's possible to leave a comment as registered users to the site, accessing through social, wordpress account or as anonymous users. If you want to leave a comment as an anonymous user you will be notified by email of a possible response only if you enter the email address (optional). The insertion of any data in the comment fields is totally optional. Whoever decides to insert any data accepts the treatment of these last ones for the inherent purposes of the service that is the answer to the comment and the strictly necessary communications.

Leave a Reply