I would try something like below. Since current_user_can
is called right before displaying the link, we have to hook where capabilities are checked.
function wpse200630_has_cap_check( $allcaps, $caps, $args, $user ){
if( function_exists( 'get_current_screen' ) ){
$screen = get_current_screen();
if( $screen->base == 'edit' && $screen->post_type == 'my_post_type'){
if ( 'edit_post' == $args[0] || 'delete_post' == $args[0] ) {
if( !empty( $args[2] ) && $args[2] == ID_TO_DISABLE )
return array();
}
}
}
return $allcaps ;
}
add_filter( 'user_has_cap', 'wpse200630_has_cap_check', 10, 3 );
Related Posts:
- What are the standard admin CSS id/class tags?
- how to know if admin is in edit page or post [duplicate]
- How to remove entire admin menu?
- The website cannot display the page
- Set Default Admin Colour For All Users
- This CSS Stuffing Works, But Is This A Good Practice?
- How can I target WordPress 3.8 new interface MP6 with CSS?
- Settings API – easiest way of validating checkboxes?
- initial sort order for a sortable custom column in admin
- Uploading files in admin panel?
- Redirect Admin User in Dashboard
- Read only capability for custom post in admin area
- How can ‘admin_email’ be set?
- How to change WordPress default strings?
- Remove ability to access certain admin menus
- Gutenberg “Add Block” button is not active (greyed out), cannot add new blocks
- How To View Site from Non-Logged-In User’s Perspective
- Conditional check for front-end which includes ajax
- Hide update messages from non-admin users?
- Daily notices of failed login attempts for non-existent admin user
- Reorder plugin items in the admin menu
- Wrong url in sortable column headers & pagination in the admin, when behind a proxy
- Reference external file as a function
- “Automatically add new top-level pages” Default
- Is it possible to hook AJAX to UPDATE-button?
- Get email address of type Administrator
- Check if user is logged in else login page
- Which hook for processing plugin page form data?
- Calling a shortcode in the backend
- Add tabbed menu to admin page
- Is there a way to have admins that are logged in to wordpress not have to enter the password for password protected pages while browsing the website?
- WYSIWYG – Getting the “link” button from HTML mode in Visual mode
- Error thrown. Cannot create references to/from string offsets
- How to receive security update notification email?
- Include admins in author drop-down on edit post screen
- How can I restore admin capabilities?
- How to restrict wp-admin and prevent upload errors
- Adding another “Add Post” button to admin
- Admin page redirect to another admin page
- How to determine if an admin is logged in outside the loop
- What determines whether admin toolbar is shown to a logged-in user?
- Adding text in more than one language (at the same time)
- How to get view count of every page on site and add that (increasing) number to Dashboard Widget
- Restrict function call to page load but not ajax call
- How do I remove All and Published if not admin?
- How to disable https from wordpress site?
- Fatal error: Exception thrown without a stack frame in Unknown on line 0
- Apply permissions per post
- Where should I hook into admin?
- Settings API not saving values to database
- Dashboard menu missing
- How to remove wp panel for users
- Unable to upload image using the standard uploader in the WP admin (v4.3)
- Admin role not really admin
- Fixed layout for admin section
- Featured image on post edit page not loading over HTTPS
- Copying WordPress site, HOW about the DB connection?
- How do I diagnose a plugin resource 404?
- Add menu item to edit specific page
- Post editor is 89953px tall. How to fix?
- Does an administrator access allow someone to access to the WordPress database?
- Change Name of Category Heading in New Post
- How to make sure your admin doesn’t hi-jack you site?
- Admin bar is disabled in front
- “sufficient permissions” error for admin after duplicating WP database to new install
- Posts in sidebar only by admin
- Display an image of selected template in admin to aid user when using complex templates
- How to remove the default checked attribute from inputs in admin?
- Passing state from child component to parent component in a Gutenberg Sidebar
- I can’t enter the control panel of my wordpress site after channing the URL to https://
- Admin user column sort by numeric meta key
- Shop in Subdomain feeding main domain order in admin area
- Can I retrieve Published changes when changes have been Saved but not Published in WordPress Semplice?
- Error 404 Display on otherlinks apart from homepage
- I can’t access login page
- Admin Access for specific page(s)
- Get Link of Page Selected through a Select Field in Custom Admin Page
- Sortable admin columns by 0.00 number
- WordPress Admin Thickbox: Remove Margins/Padding
- how to disable the e-mail verification on wp-admin/options-general.php multisite admin e-mail
- How to change the title attribute for the WP logo image on wp-login.php
- WordPress Admin Email
- conditionally update css on edit.php
- Simple CSS admin pagination
- Can I show the tag admin interface on a post when logged in as an admin?
- WordPress “Hide WP” Gives Me Error After Admin Login [closed]
- Editing post in admin panel
- Making a custom upload form and page in the admin section
- site admin for subscribers
- Customise the add media pop-up to include rel attribute option
- WordPress gallery image link gives 404 when not logged in
- Custom Div with links on Admin Bar
- WordPress admin loads erratically “connection reset by peer”
- Remove “minor-publishing” div from Publish admin metabox
- How to fix broken admin Thickbox?
- New User Notification – Setting Email
- Can’t access my wp admin: captcha images invisible, gives me error message
- Pull Random Images From Options Page [closed]
- You do not have permission to access this document on form submit
- Woo Commerce Settings for Check-out Form [closed]