更新:
再次阅读mike的答案让我想到,您可以为角色添加新功能,并在删除条件时使用该功能,因此:
// first add your role the capability like so
// get the "author" role object
$role = get_role( \'administrator\' );
// add "see_all_menus" to this role object
$role->add_cap( \'see_all_menus\' );
//then remove menu items based on that
function remove_those_menu_items( $menu_order ){
global $menu;
// check using the new capability with current_user_can
if ( !current_user_can( \'see_all_menus\' ) ) {
foreach ( $menu as $mkey => $m ) {
//custom post type name "portfolio"
$key = array_search( \'edit.php?post_type=portfolio\', $m );
//pages menu
$keyB = array_search( \'edit.php?post_type=page\', $m );
//posts menu
$keyC = array_search( \'edit.php\', $m );
if ( $key || $keyB || $keyC )
unset( $menu[$mkey] );
}
}
return $menu_order;
}
//Then just Hook that function to "menu_order"
add_filter( \'menu_order\', \'remove_those_menu_items\' );
旧答案
我完全同意mike发布的内容,但如果您不符合自定义编码,请查看Admin Menu Editor 插件。
它允许您按级别设置访问权限。