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;
if(
'post' != $current_screen->post_type
|| 'trash' != $_GET['post_status']
)
return;
if( !current_user_can( 'delete_plugins' ) )
{
wp_redirect( admin_url() . 'edit.php' );
exit;
}
}
Related Posts:
- Hiding posts from non logged in users
- Restrict access to post if it is currently being edited
- Undelete post (untrash)?
- How to restore permanently trash page? [closed]
- When trashing a post, also trash related comments
- Remove Featured Image & All Media Uploaded to the Post
- SQL Command for restoring trashed comments
- How can I set a maximum allowed post size and number of posts submitted?
- How can i take all ids from untrash_post action?
- Run Jquery Script after delete post in front end
- Trash a post, send associated comments into the trash bin (change status)
- How to change the case of all post titles to “Title Case”
- How set featured posts using checkbox in post edit screen?
- Post/Page Preview Template
- Convert custom fields to post categories
- Get names of authors who have edited a post
- Display posts by tag on page
- How to batch update post content with custom post meta value
- Most viewed post for the last 2 days using WP_Query
- Have save_post write to database image meta [closed]
- WordPress get posts by date without query_posts
- WP_Query only ONE post, won’t work
- Pagination not working on custom query
- Importing New Posts from Live Site into Local Dev Site
- PHP Notice error (when on 404 page)
- WordPress’ visual editor messing up my (nested) lists (and other things as well)
- Disabled wp-cron, set up system cron but still have missed schedule posts
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Make view count for pop up post
- add_rewrite_rules for type of post
- Trigger a Link once a new post is Published
- Edit custom post type admin menu link
- Inserting custom data to the_post() during loop
- How can I get the media inside a post?
- Permission issue with custom post type – not added to menu – by plugin
- Get Page ID of blog homepage
- Get Image tag from content of post
- Visting slug for ‘post’ post type shows 404 not archive?
- Trying to alter the post_content through the_post
- Automatically create a new page daily with last three posts
- Add filter to the end of the post
- How to add a class to each individual post?
- Indirect modification of overloaded property WP_Post::$ancestors has no effect
- How do I change the location of post-specific information?
- ACF to select posts not displaying on blog page
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
- How can I insert a new markup element after 4 posts automatically? [closed]
- the_excerpt is displaying excerpts of every post
- How to remove “» (title of post or page)”?
- Extract wordpress posts content and category content
- Post: how to set created date after post has been published [closed]
- WordPress loop not working on static front page
- Sidebar on single.php not showing up
- remove all custom post created
- Multiple Blog Pages
- Hide content from Post Preview
- How to get the next and previous image title from attachment or gallery?
- Adding if statement into the_content()
- Pagination for posts inside a specific category
- Change modified date to current date when title updated automatically
- Creating a redirect option for current page url
- How to edit a custom theme?
- WordPress posts have a different URL to the index
- how to Update guid = “text”+post_name?
- SQL DELETE multiple post_meta on single and multi-sites
- How to put the author of the post in the comments?
- Blog posts pagination not working
- unable to write to the database while uploading images
- How to Best Create Separate Subscribers and User Experience
- Post not using taxonomy template
- query posts with selected post ids first
- How can I create a Survey Form in WordPress that users can fill in and then submit the entire survey contents as a post?
- How to display related post from same category in single.php
- Save All Post Permalink From A Specific Category into a .txt file
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Using WP page password protection as defacto login
- get current index of post content in category page
- Permalink structure for two seperate blogs
- wp_query args with relation
- How do I apply a wordpress function to something with no ID inside an archive page?
- Add new post only in assigned category
- Creating Ordered Query using Meta_key
- WordPress each user has each content for a page,how to do that?
- How to change post template via url?
- How to remove related post from home page
- Is there a Standard Format for Clean URLs for Archives of Custom Posts?
- Send/Publish a Post front end
- How do I list categories and the common categories for posts beneath those categories?
- Post restoration
- Insert new post for each user infinite loop error
- Last three posts not being put in order by date. How to fix this?
- WordPress sub-posts and permalinks
- Assign a link of a post to that contains that post?
- wp_query posts sorting doesn’t work
- Show List of Posts With Comments Open
- When and how will php code in a user made WordPress page be executed?
- How to remove a date from wordpress post
- wordpress pinboard theme [closed]
- There is a page on my website that doesn’t show in the Pages section of WordPress [closed]
- Difficulty hiding a span per a body class within WordPress