Created
September 13, 2020 19:24
-
-
Save patrickfreitasdev/d84563215ea7d13e5732366794b45bd2 to your computer and use it in GitHub Desktop.
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
<?php | |
add_action( 'init', function (){ | |
if( current_user_can('editor') ){ | |
add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id, $args ) { | |
$to_filter = [ 'edit_post', 'delete_post', 'edit_page', 'delete_page' ]; | |
$currentPage = get_the_ID(); | |
$disallowEditing = array('440'); | |
if ( ! in_array( $cap, $to_filter, true ) ) { | |
return $caps; | |
} | |
if ( in_array($currentPage, $disallowEditing) ) { | |
return [ 'do_not_allow' ]; | |
} | |
return $caps; | |
}, 10, 4 ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment