Prevent Authors/Editors from deleting posts and pages
-
Hi, I’d like to have my site Authors (Editors in Buddypress) unable to delete the posts and pages at my site (that I created). I tried the code below (from the link below, swapping “author” for “editor”), but it didn’t work (also tried it with author instead of editor to no avail).
function wpb_change_editor_role(){
global $wp_roles;
$wp_roles->remove_cap( ‘editor’, ‘delete_posts’ );
$wp_roles->remove_cap( ‘editor’, ‘delete_published_posts’ );
$wp_roles->remove_cap( ‘editor’, ‘delete_pages’ );
$wp_roles->remove_cap( ‘editor’, ‘delete_published_pages’ );
}
add_action(‘init’, ‘wpb_change_editor_role’);Code originally found here: https://www.wpglobalsupport.com/prevent-authors-deleting-posts-wordpress/
Any idea how I could code this correctly so it works as intended?
Thanks!
- You must be logged in to reply to this topic.