Created
March 2, 2015 08:36
-
-
Save danieliser/8beadd05d66f233cd2fa to your computer and use it in GitHub Desktop.
Prevent users from deleting a specific page, post or CPT in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prevent_default_theme_deletion($allcaps, $caps, $args) { | |
$post_id = 123; | |
if ( isset( $args[0] ) && isset( $args[2] ) && $args[2] == $post_id && $args[0] == 'delete_post' ) { | |
$allcaps[ $caps[0] ] = false; | |
} | |
return $allcaps; | |
} | |
add_filter ('user_has_cap', 'prevent_default_theme_deletion', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment