admin - Make certain pages uneditable by editors?

My Wordpress page has a few editors. They need this permission because they need to be allowed to change the postspages

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?

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?

Share Improve this question asked Jun 23, 2015 at 8:39 HedgeHedge 1334 bronze badges 2
  • Please show us what have you tried so far. – Nilambar Sharma Commented Jun 23, 2015 at 9:39
  • I think it's also possible to use the user_has_cap filter. – birgire Commented Jun 30, 2015 at 21:08
Add a comment  | 

1 Answer 1

Reset to default 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745261116a4619216.html

相关推荐

  • admin - Make certain pages uneditable by editors?

    My Wordpress page has a few editors. They need this permission because they need to be allowed to change the postspages

    3小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信