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
- Using pre_get_posts on true pages and static front pages
- How to get page title with the page ID?
- Is there a way to change the default page template selection?
- Can I have two child pages of different parents with the same name?
- How to remove administrator role in settings -> general -> New User Default Role?
- Create un-removeable user
- Replace Dashes Before Title in Page List
- Proper method to restrict non logged users into certain pages
- Modify built-in post type properties
- WordPress parent select need to be removed
- How to get the specific Page’s current ID and use it in a get_page function?
- Limit number of pages that use a specific template?
- How does wordpress calculate the page depth?
- foreach error on false boolean from get_terms
- How to get a feed for post type ‘page’?
- Make certain pages uneditable by editors?
- Multiple pages on a single page
- Show TwentyEleven header image only on home page
- Overview with latest edited posts and pages
- WordPress post/page pagination (page links) to go back to the first section
- Placing google maps into a wordpress page using the wordpress page editor
- Export only pages and posts with mysql dump
- Backend option to include a javascript file on specific pages?
- Putting footer content in a “page” – Doing it wrong?
- How to create wordpress page that shows posts with specific tags?
- Different Admin Theme – Based on Role?
- Template for child pages / subpages
- Is there a better way to programmatically insert content into a page?
- How to get the order attribute of a page
- Custom page template not working
- How to Add a Rewrite Rule for Only One Page?
- Are Pages the right thing to use for making sections of a single-page site?
- Allow contributors to create page (but not publish)
- Visiting Webpage ONLY after another page was visited. Possible?
- How do I pass data from page content to the underlying PHP template
- add new metabox to page editor with just page parent
- How to open a phpBB forum in the same website as sub-page [closed]
- Display page contain in index.php file
- How to redirect login and register pages
- How to setcookie if is_page(‘page’) ? should I use add_action(‘init’) or there is another action?
- Why do pages in WordPress have a hierarchy but menu’s also have a hierarchy?
- Text Editor Tags
- Column Images Showing Gaps
- I Changed the Menu Order, But the Page Order Didn’t Change on Front Page
- Custom page template with entirely different design. Is it possible in?
- Combining ‘depth’ with ‘include’ in wp_list_pages()
- Page template no longer exists – metaboxes won’t save
- A static page view call every custom page templates
- Wrapping images in tags based on size
- Add a static page that links to homepage
- Can I change the “Home” text in the menu?
- Search child pages from a specific page parent
- Cannot update page – with too many characters?
- Using external DB within wordpress
- Search page doesn’t recognise post_type=page