By using this functionality we can able to remove the delete option of the page or post.
function wp_restrict_page_deletion( $caps, $cap, $user_id, $args )
{
$post_id = $args[0];
if ( $cap === 'delete_post' && $post_id === your post id* )
{
$caps[] = 'do_not_allow';
}
return $caps;
}
add_filter( 'map_meta_cap', 'wp_restrict_page_deletion', 10, 4 );
I think this one is apt for your requirement.
your post id*->Here you need to give the post id of the page or posts,thats you need to remove the delete option.
Related Posts:
- Editor can create any new user except administrator
- Remove Ability for Other Users to View Administrator in User List?
- Groups of capabilities: users with multiple roles?
- User-edit role setting distinct from wp_capabilities? [closed]
- How to let contributors to create a new revision(draft) editing their published posts
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- How to update user role without logout
- How to check user role without using current_user_can()
- Do not allow users to create new posts and pages
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- How to enable the theme editor cap for an editor role?
- How to assign capabilities to user NOT to User Role
- How-to Delay The Capability To Publish Posts?
- Is there a simple way to manage capabilities per user?
- Get User Role by ID not working
- Getting users by specific capability, not role
- Are User Levels Still Currently Used?
- Remove Capabilities from WP admin for specific user role
- Add a role and give admin priviledges
- Where are $current_user->allcaps set?
- How can I prevent certain custom roles from seeing other custom roles on the user list page?
- What’s the correct way to add capabilites to user roles?
- Can I Create a Second Admin Level User Role?
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- how do I add role and capability after I create a new user
- How to make WordPress ‘editor’ role to list/view/add/edit users only with the role ‘author’?
- fine-grained capabilities for user related capabilities
- Groups roles & capabilities
- Subscriber role – blank page
- current_user_can() returning true for capability when the user and role do not have the capability
- If the current user is an administrator or editor
- How to allow an user role to create a new user under a role which lower than his level only?
- What’s the difference between the capability remove_users and delete_users?
- Allowing users to edit only their page and nobody else’s
- alphabetically order role drop-down selection in dashboard
- Execute a function when admin changes the user role
- How to let user set password on registration
- How to hide media uploads by other users in the Media menu?
- Prevent user creating new users with specific roles
- Return ID of authors who have at least one post
- Front end user meta options for users
- How do I properly format the user_role array?
- Prevent Admin user to edit/see super admin from users list
- Redirect after login based on user role (custom login page)
- How can I check if the admin bar is visible to the current user?
- Creating a Front-end based User Search
- Can I create users that have access to *some* other users posts instead of all other users posts?
- Set default page for user account in admin
- User role permissions based on taxonomies
- Delete user from frontend
- Tagging users in WordPress
- Front End Registration Form Code – Password Field Not Saving
- Hide everything on site for visitors except specific page IDs
- current user can edit user?
- the_author_meta(‘user_url’, $author->ID) not working properly. how can I solve this?
- Register new user in the frontend
- add_cap not working with Shop Manager role
- Multiple Backend Users as single Frontend User
- Restricted registrations or removing the ability to edit your password/email
- Roles for Custom Post Types
- Does an AJAX call on the Admin Side Automatically include the User Data/Capabilities?
- Updating wp_user_level on user update
- Force user to change their password on the frontend at the first login and password policy
- How to get a users list by who created them?
- Does wordpress support natively the concept of logging-in users? (not admins, but users of the website)
- How many people are allowed to use same wordpress account at the same time?
- Restrict access to non-wordpress section of site with user roles?
- How to hide user profile fields based on the role of the viewed user?
- Does it matter if the very first user, usually Admin, does not have a user ID of 1?
- Customising “user ids” and add to ‘user’ panel in the admin area
- How to hide some users to unlogged users [closed]
- List all users and current week entries
- Groups and subgroups for permission
- Redirect admin 403 “Cheatin uh?” admin pages
- Remove specific administrator’s capability
- Privilege to recover trashed posts
- Get Authors Role
- WordPress user role with create user capability?
- User can’t search himself on rest api
- Allow a user or role to view drafts and previews, but not other admin privileges?
- current_user_can() causing critical error
- Update user role for expired membership
- How to hide “Change role to” dropdown on Users admin menu
- Author Error “Sorry, you are not allowed to access this page.”
- Hook into add_user_role and update based on new and removed roles
- How to Moderate Edits to User Profiles?
- Create relationships between users or user roles
- User Permissions on custom post type
- WordPress install checking permissions of user id 0
- Allowing users to edit only their page and nobody else’s
- How to bulk change user role to “No role for this site”
- Add an ‘edit profile’ page with Genesis
- User count only for role frontend vendor
- Limit roles displayed in users.php depending on custom role
- Creating Custom user type just like custom post
- Let admin users edit member profiles from front end
- Control Category of each user can post
- Giving users an editable homepage/business directory
- Want to add post to user dashboard
- Show only users with the same role in Dashboard user list