Managing multi-author blog is not an easy task. You have to take lots of cares to keep control of content. Authors can not just publish their posts but they can also delete their own posts. If you do not want to allow authors to delete their posts, you have no default option on WordPress to set this. But, you can still do this. In this article, I will show you how to prevent authors from deleting their own posts in WordPress. By using ways given in this article, you can quickly disable the Delete Post option from their dashboard. And they can no longer delete any of the posts they have written on your blog.
Why Prevent Authors From Deleting Their Own Posts in WordPress
There could be lots of reason for preventing authors from deleting their posts. There have been many incidents in past when authors didn’t work properly and when asked to leave, they deleted all the posts written by them. So, it is better to block them from deleting their posts. If there is any need to delete a post form past, admin should do it from his/her end.
Disable Delete Post Option for Authors in WordPress
Now take a look at ways to prevent authors from deleting posts. I am listing two ways of doing this. You can either do it by adding a code in functions.php or install a plugin for better control over the whole functionality.
Manually Prevent Authors From Deleting Their Own Posts By Modifying Theme code
If you know how to modify theme files, you need to use this way. The method can make your website down if you do anything wrong. If you are not a developer, I recommend you to try the Plugin way, that I have added later in this article.
You can either add the following code directly to the functions.php file or create a site-specific plugin. The site-specific plugin makes sure that you do not lose your code even if you change the theme in future.
Use this code to revoke access to delete option
$wp_roles->remove_cap( 'author', 'delete_posts' );
$wp_roles->remove_cap( 'author', 'delete_published_posts' );
Use this code to give access to delete option
If you want to revert back the permissions, removing the added code will not help. You need to remove the code and add another code to define new permissions. SO replace the previously added code with this new code.
$wp_roles->add_cap( 'author', 'delete_posts' );
$wp_roles->add_cap( 'author', 'delete_published_posts' );
Now you know how to do this by modifying code. If you do not want to edit code, you can try the next way that uses Plugin.
2. Use Plugin to Prevent Authors From Deleting Posts
This method is easier and recommend. You need to install and active the WordPress plugin called. If you are not sure how to do this, read our step by step guide on how to install a WordPress plugin.
After installation, this plugin adds a new option ‘Capabilities’ under ‘Users’ menu. Go to this page and you will get access the page where you can change the permissions of a user. Not just delete a post, you can also change editing permissions as well.
You need to select the role from the drop-down at the right side of the page to load the existing permission. The make changes as per your need and save. You can also create a new role and assign permission as per your requirements.
You can always alter the permissions and make changes as per your need.
Note: Uninstalling this plugin will not revert back the changes. You need to manually do that before uninstalling this plugin.
There is also an option to reset all the changes made by this plugin. visit Tools » Capability Manager page and click on ‘Reset to WordPress defaults’ link. It will revert back to default WordPress capabilities. Then you can safely remove this plugin.
Now you know how to change permissions of an author and revoke access to delete option. If you want to prevent authors from having access to delete posts option, you can use any of the given ways. I recommend you to go with the second option that uses the plugin. It will be easier and safe. If you do not understand code, using the first method is risky.
I hope this article was clear. If you still have anything to ask, you can always leave a comment.