我终于找到了解决办法。
function checkUserPermissionsInThisScreen(){
if (is_admin()){
$currentUserRoles = wp_get_current_user()->roles;
if (in_array(\'shop_manager\', $currentUserRoles)){
$a = get_current_screen();
if ($a->id != \'edit-shop_order\' && $a->post_type != \'shop_order\'){
wp_die(\'you do not have needed permissions to see this page\');
}
}
}
}
add_action(\'current_screen\', \'checkUserPermissionsInThisScreen\');