Easy Ways to Prevent Authors From Deleting Posts in WordPress Website

Here we are going to expose how to Prevent Authors from Deleting Posts in WordPress? By default, most of the users with the author user role can delete their own posts when these posts are already published.

While running a multi-author blog, you may want to stop authors from deleting their own posts specifically once it’s published. This post, help you how to simply prevent authors from deleting their own posts in WordPress.

Read More: 3 easy Methods to Remove Author name from WordPress Posts 

Why Limit Authors From Deleting Their Own Posts in WordPress Website

WordPress is important for user role management system. WordPress site is assigned a user role for all registered user and all the user role comes with the permissions.

With an author role, a user can write posts and publish them on your website. Multi-author WordPress blogs use this role.

The author has the power to delete their own posts. The website owner, prevent the authors from doing that. The simple way to do this by changing the author user role and its permission in WordPress.

Look at the methods to simply prevent authors from deleting their own posts.

Method 1: Prevent Authors From Deleting Posts By Using Plugin

This method is simple and recommended for all users.

  • First of all, you can install and activate the Capability Manager Enhanced plugin.
  • After activation, visit Users » Capabilities page. In this, you need to load any WordPress user role and change its capabilities and permissions.

capabilities

  • You can start by locating the ‘Select Role to View / Edit’ box in the right column.
  • Next, select ‘Author’ user role from the drop-down menu. Click on the ‘Load’ button to load the author user role capabilities.

loadauthorrole

  • The plugin loads the ‘Author’ user role capabilities. Beneath the deletion capabilities section, you can uncheck the box next to delete and delete published options. Just move ahead to the bottom of the page.
  • Click on the save changes button to store your settings. The user will not able to delete any posts on your WordPress site by following these steps.

Allow Back Permissions

Directly you can be defined user role capability. Means that if you remove the capability from a user role it does not come back either if you directly defined it again.

By default, if you uninstalled the plugin, the capability will change it will not return automatically.

If you grant authority to delete the back author permission. For doing this you will repeat the process and check the boxes next to delete. Delete published posts option also. Now, if you uninstall the plugin you can return back to default WordPress capabilities firstly you need to visit Tools » Capability Manager page and click on ‘Reset to WordPress defaults’ link.

Method 2: Manually Prevent Authors From Deleting Their Own Posts in WordPress

This method needs to add code to your WordPress files.

Add the following code to your theme 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’);

The Code changes the author user role and removes their capability to delete their own posts.

If you return back the permission you can simply remove the code it will not make any changes. Just redefine the removed capabilities by replacing the first code with the below-given 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’);

CONCLUSION

You know how to change permissions of an author and revoke access to delete option. Prevent the author from having access to delete post option, you can use any method described above.

I suggest you go with the first method that uses the plugin. It will be simple and safe. As the second method is complicated for the user who doesn’t understand the code.

We have a well qualified team of professional who can solve your problem related to WordPress Security. Dial our Toll-Free number + 1 844 275 0975 for instant help and support.

Read More Blogs:



Leave a Reply

Call Now