在后端,如何限制编辑器(具有编辑器角色的用户)查看/编辑由管理员(和/或管理员角色)创建的页面?
我知道WordPress中的编辑器角色具有“edit\\u others\\u pages”功能,但我需要一个自定义功能的函数,如:“edit\\u others\\u pages\\u except\\u admin”:
我不想仅仅为了这个而使用一个庞大/复杂的插件!
谢谢我搜索了一个解决方案超过1h:D
在后端,如何限制编辑器(具有编辑器角色的用户)查看/编辑由管理员(和/或管理员角色)创建的页面?
我知道WordPress中的编辑器角色具有“edit\\u others\\u pages”功能,但我需要一个自定义功能的函数,如:“edit\\u others\\u pages\\u except\\u admin”:
我不想仅仅为了这个而使用一个庞大/复杂的插件!
谢谢我搜索了一个解决方案超过1h:D
此代码将完成此工作。。。
<?php
add_action(\'pre_get_posts\', \'filter_posts_list\');
function filter_posts_list($query)
{
//$pagenow holds the name of the current page being viewed, we want to run our code only on edit.php (posts list)
global $pagenow;
//If the \'Editor\' is logged in, exclude \'Admin\'s posts
if(current_user_can(\'editor\') && (\'edit.php\' == $pagenow))
{
//global $query\'s set() method for excluding admin\'s posts
$query->set(\'author\', \'-1\');
}
}
有关详细说明Read Here.我想为一组用户类型(编辑器+自定义角色)提供添加用户/创建用户功能。唯一需要注意的是,我想将该功能限制为仅添加“订阅者”类型的用户,除此之外没有其他功能。有没有办法做到这一点?