How to prevent Authors from editing or deleting WordPress posts

Share this article:

A quick-win with WordPress – say you hired authors to posts articles on a blog, and have got a process like the following:

  • The authors post their post under “draft” mode
  • An editor is approving or scheduling the post

Issue is, that by default, WordPress Authors couldn’t touch other authors’ posts, but they could potentially delete or update their own posts even after they were posted. To prevent them from doing so, you need to add the following lines in the end of your WordPress functions.php file (in our dashboard, goto “appearance” -> “Editor” and look for the functions.php file to do so):

 

/********* PREVENT AUTHORS FROM EDITING AND DELETING PUBLISHED POSTS **********/function wpb_change_author_role(){
    global $wp_roles;
    $wp_roles->remove_cap( 'author', 'delete_posts' );
    $wp_roles->remove_cap( 'author', 'delete_published_posts' );
 $wp_roles->remove_cap( 'author', 'edit_published_posts' );
}

add_action('init', 'wpb_change_author_role');

Enjoy it 🙂

 

Eran


Share this article:

Comments

comments

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *