I want to restrict users from deleting posts permanently. How do I restrict access to the Trash folder in Posts? This is the only page were the users can delete their posts permanently.

The only solutions that I have so far is:

1) Adding this to stylesheet:

li.trash {
    display: none;

But both me and you know that this is a dummy fix and more importantly, it just hides the link that goes to the Trash folder for all users.

2) Remove the capability delete_posts for none-editors. The problem with this is that the users will not be able to move their posts to the trash folder (which is a feature that is essential for my platform).

Do you know of a better solution?

1 Answer 1


With the filter we prevent the Trash link from being printed.
And with the action, redirect back to the post listing page if the user tries to access the URL directly (/wp-admin/edit.php?post_status=trash&post_type=post).

add_filter( 'views_edit-post', 'wpse_74488_remove_trash_link' );
add_action( 'admin_head-edit.php', 'wpse_74488_block_trash_access' );

function wpse_74488_remove_trash_link( $views ) 
    if( !current_user_can( 'delete_plugins' ) )
        unset( $views['trash'] );

    return $views;

function wpse_74488_block_trash_access()
    global $current_screen;

        'post' != $current_screen->post_type 
        || 'trash' != $_GET['post_status'] 

    if( !current_user_can( 'delete_plugins' ) )
        wp_redirect( admin_url() . 'edit.php' ); 
  • 1
    Works elegantly! I'm impressed, great solution, upvoted and accepted! Commented Dec 1, 2012 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.