Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save itsKnight847/21feb0207c5db697c9037070be7a4489 to your computer and use it in GitHub Desktop.
Save itsKnight847/21feb0207c5db697c9037070be7a4489 to your computer and use it in GitHub Desktop.
prevent users from delete specific pages
add_action('wp_trash_post', 'restrict_post_deletion', 10, 1);
add_action('before_delete_post', 'restrict_post_deletion', 10, 1);
function restrict_post_deletion($post_id) {
if($post_id == 2632) wp_die('This page cannot be deleted');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment