How to Prevent Authors From Deleting Posts in WordPress

Table of Contents
Reading Time: 2 min, 25 sec
Managing a WordPress website with multiple authors can be challenging. Over the years, I have worked on sites where authors accidentally deleted their own posts or, in rare cases, removed content that was important for the site. While WordPress gives authors the ability to create, edit, and delete their own posts by default, sometimes you need to put safeguards in place to protect your content. In this guide, I will show you two reliable ways to prevent authors from deleting posts: using custom code and using a plugin. These methods are simple, safe, and effective, and they give you control over who can delete content on your site.
Method 1: Using Custom Code
You can prevent authors from deleting posts by adding a small snippet to your site. I always recommend using a Code Snippets plugin or creating a small custom plugin instead of editing functions.php directly. This keeps your site safe from accidental errors.
Best WordPress Hosting
Bluehost is one of the best and secure WordPress hosting providerfunction prevent_author_delete_posts() {
if(current_user_can('author') && isset($_GET['action']) && $_GET['action'] == 'delete') {
wp_die('You are not allowed to delete posts.');
}
}
add_action('admin_init', 'prevent_author_delete_posts');
This snippet checks if the user is an Author and is trying to delete a post. If so, it stops the action and displays a warning message.
You can also hide the delete link in the post list for authors to make it more user-friendly:
function hide_delete_link_for_authors($actions, $post) {
if(current_user_can('author')) {
unset($actions['trash']);
}
return $actions;
}
add_filter('post_row_actions', 'hide_delete_link_for_authors', 10, 2);
This prevents authors from even seeing the delete option, reducing the chances of accidental deletion.
Method 2: Using a Plugin
If you are not comfortable with code, plugins can do the job without touching a line of PHP. Two popular options are:
- User Role Editor: Lets you manage capabilities for any user role. You can uncheck the Delete Posts capability for Authors.
- Members: Allows full control over roles and permissions. You can create a custom Author role that cannot delete posts.
How to Do It With User Role Editor
- Install and activate User Role Editor from the WordPress repository.
- Go to Users → User Role Editor.
- Select the Author role.
- Uncheck the Delete Posts capability.
- Save changes.
Now, authors can continue writing and editing posts but won’t have the option to delete them.
Conclusion
Preventing authors from deleting posts is a simple but important step for content safety on multi-author WordPress sites. You can achieve this with a custom code snippet, which blocks deletion and hides links, or with a plugin for a no-code solution. Both methods are effective, and the choice depends on your comfort level with code and site management.
If you want, I can also create a ready-to-use enhanced snippet that blocks deletion for Authors and Contributors while keeping it available for Editors and Admins. This would make it completely plug-and-play.