2

My Wordpress page has a few editors. They need this permission because they need to be allowed to change the posts/pages of others. However there two pages I want only me, the administrator to be able to edit.

How can I accomplish that?

  • Please show us what have you tried so far. – Nilambar Jun 23 '15 at 9:39
  • I think it's also possible to use the user_has_cap filter. – birgire Jun 30 '15 at 21:08
3

You can try the map_meta_cap filter:

/**
 * Uneditable posts/pages for editors
 */
add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id, $args )  
{
    // Edit to your needs:
    $post_ids = [123, 234, 345, 456]; // Uneditable posts   
    $role     = 'editor';             // Uneditable by this user role

    // Make given posts uneditable for the above user role:
    if (
            'edit_post' === $cap
         && isset( $args[0] )
         && in_array( $args[0], $post_ids ) 
         && current_user_can( $role )
    )
        $caps[] = 'do_not_allow';

    return $caps;

}, 10, 4 );

to make certain pages/posts uneditable by editors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.