Add this to your functions.php in your theme folder:
function restrict_post_deletion($post_ID){
$user = get_current_user_id();
$restricted_users = array(21,25,54,2,19);
$restricted_pages = array(2,21,52,64);
if(in_array($user, $restricted_users) && in_array($post_ID, $restricted_pages)){
echo "You are not authorized to delete this page.";
exit;
}
}
add_action('wp_trash_post', 'restrict_post_deletion', 10, 1);
add_action('wp_delete_post', 'restrict_post_deletion', 10, 1);
Taken from here and updated to the latest WP version.
Related Posts:
- Check IF is a “single product page” and Check the “role” for a Redirect
- Restrict admin access to certain pages for certain users
- Can I display the widget admin in the page admin?
- Change admin startpage to Pages-page?
- Only allow new subpages to be created
- Is there a way to remove or hide individual pages on the Edit Pages screen?
- Show different badge based upon the user role
- How to disable Page Attributes dropdown in wp-admin
- How to change redirect after moving a page to trash?
- Dashboard–> All Pages “How to create folders?”
- How to make certain page templates visible to admin only
- User capability of create page/new page
- Add a Menu Link (to a WordPress Page) in the Admin Menu/Sidebar
- Remove pages from backend list *and* update counter accordingly
- remove/hide pages from users backend
- Edit page’s “Restore the backup” link does nothing
- List all private pages user has access rights to read
- Missing ‘Page Attributes’ in page edit
- Admin pages, edit notes of the title of posts and pages
- Can’t locate a hidden private page
- Role – edit page but not publish
- Restricting Pages based on Hierarchy and User Role
- Adding Page URL to the Pages Admin Table
- Role can edit just one page [closed]
- How to use is_admin in page content?
- Change page name in admin list
- logout redirect only from admin page
- Is it possible to restrict access to specific pages in the admin area based on the page slug?
- Allow a user to edit their own page and profile only
- Custom page only editable by one user
- Publish page by invoking submit via jQuery
- One author not showing in Author drop down list while editing page
- accessing the Admin page
- remove “Edit” from select pages
- Every change made by “Author” role is going to “pending review”
- Not allow add New Page for role ‘editor’
- How to limit the pages shown in the page manager to those created by the logged in user?
- Adding CSS styles to Admin Area PAGES only (not POSTS or CPT)
- Add role and edit page capabilities
- Group Pages based on Parent in Admin Area
- Custom admin menu for a selection of pages
- How to access variables from one plugin in another
- Forbid certain users to access a specific page
- How to make a secondary Pages Screen
- Remove element from admin page editing part
- how to update page without reloading the page builder?
- Add infinite scroll to content splitted post
- Check if wp-login is current page
- How to get current page ID outside the loop?
- Contact Form on WordPress Sites?
- Page returns 404 with POST variables, but not without
- Custom templates not showing up in template dropdown
- Get page id by template
- Using pre_get_posts on true pages and static front pages
- Get the content of a specific page (by ID)
- How to get page title with the page ID?
- Show more than 20 items in pages or posts edit dashboard
- Allowing user to edit only certain pages
- Remove update nags for non-admins [duplicate]
- Give Editor Access To Sidebar
- How to display last 3 posts (recent posts) in a static page?
- How to give paged links custom title?
- How to set post slug when using wp_insert_post();?
- How do I remove dashboard access from specific user roles?
- How can I keep the content of my pages version controlled?
- How to load javascript on custom page template?
- How to configure WordPress to handle 75,000 pages?
- How to update page status from publish to draft and draft to publish
- Check if is on child-page of a particular page
- Change page template programmatically ?
- Conditional tag to check if ‘page.php’ is being used?
- Customizing the URLs of WordPress Login and Sign-up Pages?
- How to disable posts and use pages only
- featured image as background image on pages
- A check for if is parent page, if has children, if has grandchildren
- How to display by default only published posts/pages in the admin area?
- How to load JS and CSS only on specific Pages using is_page()?
- Listing pages which uses specific template [duplicate]
- Proper way to get page content
- Access the same page from multiple urls (wildcard)
- Create a page without adding a page in the Database
- Is there a way to change the default page template selection?
- Can I have two child pages of different parents with the same name?
- What methods to use to create small, editable pieces of text for static pages?
- Show Default Editor on Blog Page ( Administration Panel )
- Hide page visual editor if certain template is selected?
- What is the difference between $paged and $page?
- Any guides on creating custom admin pages?
- multi page password protection
- Create a “Dummy” parent page for a hierarchy in page listing?
- How do I convert a page’s title to lower case?
- Get top level page parent title
- How to add a specific widget to only 1 page?
- page title, parent tilte and grand parent title
- How to add jQuery script to an individual page?
- WordPress page edit does not save selected template
- Add a Page without header and menus?
- What is an alternative to get_page_by_title()?
- Password protect page with multiple passwords
- Create pages automatically if they don’t exist