Skip to:
Content
Pages
Categories
Search
Top
Bottom

Prevent Authors/Editors from deleting posts and pages

  • @a7xfanben

    Participant

    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!

Viewing 1 replies (of 1 total)
  • @a7xfanben

    Participant

    I tried it in the theme functions.php file, as multiple online tutorials recommended.
    If there is a way to add it directly into the Buddypress plugin via plugin file editor, which Buddypress file should it be added to?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar