To keep up with the high demand for content, many websites build a large team of content writers. Unfortunately, sometimes content writers are not on the same page and accidentally delete posts they shouldn’t. Luckily, we can stop them from deleting posts with a plugin.
To do this, we will use the PublishPress Capabilities plugin, which allows us to change what certain user roles can and can’t do in WordPress. In this case, we can make it so Authors cannot delete posts.
In general, this ability should only be granted to editors or the admin. There are exceptions, but it’s a good rule of thumb to limit every role’s ability to just allow them to do their job and no more.
Today, I will demonstrate how to stop authors from deleting WordPress posts with PublishPress Capabilities.
Make Sure User Roles Have the Necessary Permissions
One of the biggest criticisms of the User Role system in WordPress is that there is a lack of customization available.
Now, this is not true. You can edit the permissions of every user role in WordPress, but the caveat is that it requires code to do so. And when your platform is well known for not needing code, well, it becomes an issue.
Generally speaking, you want each user role to carry out the tasks they are assigned and nothing more. The problem is that user roles have a lot of power in WordPress and sometimes you need to remove certain options.
For example, let’s say you allow contributors to create posts for your website. You’ll review the post and publish it. Fast forward a few months and if that contributor needs to make an edit, they don’t have permission.
This can be problematic, so you can allow contributors to edit posts by changing them. Now, whether that’s a good idea is a different story. But the point is there are multiple circumstances where you may want to change the default features of a role.
Luckily, with the PublishPress Capabilities plugin, this is really easy to change those settings for each user.
Method 1: Using PublishPress to Edit Author Roles
The PublishPress Capabilities plugin is a very simple plugin that allows you to change what each user role has access to on your website. For instance, you can stop authors from deleting posts.
While this will be the focus of the tutorial, be aware that you can do a lot more for every user role. You can give users the ability to read or write in posts and pages or take that ability away.
The same is true for the ability to publish a post or set a post back to draft status. Just make sure the people within that user role need that ability. Giving the wrong user that ability can cause serious problems.
Step 1: Install PublishPress Capabilities
Let’s start by clicking on Plugins and selecting the Add New option on the left-hand admin panel.
![Add New Plugin](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/Add-New-2.png)
Search for PublishPress Capabilities in the available search box. You should immediately see a series of plugins with the name PublishPress. They make a variety of amazing plugins for just about everything.
![Search for PublishPress Capabilities to stop authors from deleting posts](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/PublishPress-Capabilities.png)
Locate the PublishPress Capabilities plugin and click on the “Install Now” button and activate the plugin for use.
![PublishPress to Prevent Deleting Posts](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/Install-Now-3.png)
Step 2: Locate The Deletion Options
Preventing Authors or any user role from deleting posts is incredibly simple. There is a dedicated section for just about every major area of WordPress. All you need to do is go to that section, select the user role, and change permissions.
It really just boils down to checking the right box in the correct location.
On the left-hand admin panel, click on Capabilities and select the Capabilities option.
![Select Capabilities](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/Capabilities.png)
There is a list of vertical tabs. They include things like Edit, Plugins, Taxonomies, and much more. For the purpose of this tutorial, click on the Deletion tab.
![Click on the Deletion tab to customize what roles can delete posts](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/Deletion-Tab.png)
Step 3: Remove the Author Roles Ability to Delete
On the top left side of the screen, there is a drop-down box to select the User Role you want to customize. In this case, select the Author Role from the drop-down menu.
![Select Author](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/Select-Author.png)
You can select between posts and pages, as they have separate configurations by using the drop-down menu. The default is Posts, so no need to change it.
You can see if a user role has the ability to carry out a specific action if there is a checkmark in the box.
If the checkmark is not present, they do not have permission. And if a red X is present, they cannot be given permission by another user role besides the site admin.
In the case of post deletion, an author can do it, so it has a checkmark. Simply uncheck the box to remove the ability.
Note: There are multiple deletion options. You can remove all of the checks as necessary.
![Uncheck to Stop Deleting Posts](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/Uncheck-Box.png)
Click on the “Save Changes” button to finish.
Congratulations on learning how to stop an author from deleting posts in WordPress. Remember, you can customize every aspect of your user roles with this plugin, so be sure to explore the other sections.
Method 2: Manually Preventing Authors from Deleting Posts
I said this at the start; it’s completely possible to take away the ability for authors to delete posts, but it requires coding. Now, that may have scared a lot of people, but it really shouldn’t.
In reality, it boils down to copying and pasting a few lines of code in the functions.php file.
Step 1: Access the functions.php File
There are several ways to access this file in WordPress. You can access it from the cPanel, use an FTP application like FileZilla, or do it directly from WordPress by using the WordPress Editor.
For this tutorial, I’m simply going to load up the Editor so I can demonstrate the code.
Go to Appearance and click the Theme File Editor Option. This name may be slightly different depending on the theme you have installed.
![Theme File Editor](https://www.greengeeks.com/tutorials/wp-content/uploads/2022/12/Theme-File-Editor.png)
Make sure you’re working from your current theme (should be the default option). Click the functions.php file from the right column. It should be labeled something like “Theme Functions.”
![Functions](https://www.greengeeks.com/tutorials/wp-content/uploads/2018/01/Functions.jpg)
Step 2: Add The Code
Before continuing, it’s worth noting that it is highly recommended to use a child theme whenever possible. It protects the primary theme from being altered incorrectly and makes it easy to recover if something goes wrong.
Also, always get in the habit of creating a backup of your site when making these kinds of changes. It can come in handy should you need to revert should something break the site.
Simply copy the following lines of code and paste them into the functions.php file:
function wpb_change_author_role(){
global $wp_roles;
$wp_roles->remove_cap( 'author', 'delete_posts' );
$wp_roles->remove_cap( 'author', 'delete_published_posts' );
}
add_action('init', 'wpb_change_author_role');
![Add Code](https://www.greengeeks.com/tutorials/wp-content/uploads/2018/01/AddCode.jpg)
Click the “Update File” button at the bottom and your authors will no longer be able to delete content.
![Update File](https://www.greengeeks.com/tutorials/wp-content/uploads/2018/01/UpdateFile.jpg)
Step 3: Reverting the Code
If further down the line you change your mind and want authors to be able to delete posts, it’s not as simple as removing the code. Instead, you actually need to change the code you added.
Simply paste the following code over the code you added in the previous step:
function wpb_change_author_role(){
global $wp_roles;
$wp_roles->add_cap( 'author', 'delete_posts' );
$wp_roles->add_cap( 'author', 'delete_published_posts' );
}
add_action('init', 'wpb_change_author_role');
![Add Deleting Posts Snippet](https://www.greengeeks.com/tutorials/wp-content/uploads/2018/01/AddDelete.jpg)
Again, save the changes, and the ability to delete posts is restored.
Manage Your Team
Controlling what your employees have access to is important whether you are running a website or a physical location. You wouldn’t normally want your cashier to know the safe code right?
Having access to deleting posts is a similar concept. They just don’t need that power to carry out their jobs. It’s more power that only editors should have. Of course, you could disagree and want the role to have more power.
Regardless of your preference, the PublsihPress Capabilities plugin has you covered.
What abilities do you give your authors when it comes to creating content? Do custom roles play a part in your website development?