Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Prevent Authors From Deleting Posts in WordPress

By default, users with the author user role can delete their own posts, even when these posts are already published. If you run a multi-author blog, then you may want to stop authors from deleting their own posts specially once it’s published. In this article, we will show you how to easily prevent authors from deleting their own posts in WordPress.

How to prevent authors from deleting posts in WordPress

Why Prevent Authors From Deleting Their Own Posts in WordPress

WordPress comes with a powerful user role management system. Each registered user on your WordPress website is assigned a user role, and each user role comes with different permissions.

Users with the ‘author‘ role can write posts and publish them on your website. This role is generally used by multi-author WordPress blogs.

Authors can also delete their own posts, including those already published. As a website owner, you may want to prevent authors from doing that. The easiest way to do that is by modifying the author user role and changing its permissions in WordPress.

Let’s take a look at how to easily prevent authors from deleting their own posts.

Method 1: Prevent Authors From Deleting Posts Using Plugin

This method is easier and recommended for all users.

First thing you need to do is install and activate the Capability Manager Enhanced plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Users » Capabilities page. Here you can load any WordPress user role and change its capabilities and permissions.

User roles and capabilities manager

You need to start by locating the ‘Select Role to View / Edit’ box in the right column, and then select ‘Author’ user role from the drop down menu. After that you need to click on the ‘Load’ button to load the author user role capabilities.

Load author user role

The plugin will now load the ‘Author’ user role capabilities. Under the deletion capabilities section, you need to uncheck the box next to delete and delete published options.

After that you can go to the bottom of the page and click on the save changes button to store your settings.

Now, users with the author user role will not longer be able to delete any posts on your WordPress site.

Giving Back Permissions

User role capabilities are defined explicitly. It means that once you remove a capability from a user role, it will not come back unless you explicitly define it again. Even if you uninstalled the plugin, the capability changes you made will not revert automatically.

If you want to give back authors permission to delete, then you will have to repeat the process and check the boxes next to the delete and delete published posts options.

If you want to uninstall the plugin and revert back to default WordPress capabilities, then first you need to visit Tools » Capability Manager page and click on ‘Reset to WordPress defaults’ link.

Reset user role permissions

Method 2: Manually Prevent Authors From Deleting Their Own Posts

This method requires you to add code to your WordPress files. If you haven’t done this before, then take a look at our guide on how to copy and paste code in WordPress.

You will need to add the following code to to your theme’s functions.php file or a site-specific plugin.

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');

This code changes the author user role and removes their capability to delete their own posts.

If you want to revert back the permissions, then simply removing the code will not make any change. You will need to explicitly redefine the removed capabilities by replacing the first code snippet with the following code:

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');

We hope this article helped you learn how to prevent authors from deleting their own posts in WordPress. You may also want to see our ultimate step by step WordPress security guide for beginners.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

1 CommentLeave a Reply

  1. Hi i am very greatful on all the content you create on this site, i have always found it extremely useful and a go to point for any problems i face…i am little stuck with my wp site at the moment and really hope you can shed some light on the matter.

    I want to create a site where there are buyers and sellers.

    Firstly i wanted buyers to register and be allowed to see content after they have paid..also theh need to be able to upload a few pictures.

    Secondly i wanted sellers to register and also be able to post after they paid. And have access to restricted content.

    For both users they can register or on seperate pages or select from a drop down menu that a person is a seller or buyer.

    Once selected as a buyer, buyer should be able to select a category of interest.

    I wanted the sellers account to automatically be have a certain user role and same for buyers.

    Is this possible or would i need to handle every user role manually.
    I would like users to have their own dashboard where they can upload items for sale etc..

    I really hope you can help thanks in advance.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.