- 6 years ago
- Zaid Bin Khalid
- 4,051 Views
-
16
You can limited rights of an author in the multi-author website without plugin. If you are running a multi-author website then you are curious about the rights of the author. In this tutorial, I am going to show you how you can limit the post rights of the author.
By default in WordPress, every author only can view other author posts. They are not allowed to edit the other author posts, but if you want to change the view you can do that using a simple function. After using this below function every author can view his/her own post data in WordPress POST page.
Step 1
Open a functions.php file and copy past below snippets at the end of the page.
<?php
function current_author_post($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','current_author_post');
?>
That’s it, now logout and login again to see the difference.
- 6 years ago
- Zaid Bin Khalid
- 4,051 Views
-
16