//由于建议的答案显然会导致一些新问题并且在其他几种情况下并不能解决原始问题,因此可以选择根据用户类型隐藏元素,如下所示 - 这有点杂乱无章,但可能会服务:
首先,加载仅适用于车间经理的管理样式表:
/**
* SHOP MANAGER STYLES
* Front (Optional) and Back End stylesheet
* Style interface for users logged in with'shop_manager' role
* Add to theme functions.php
*/
add_action('admin_enqueue_scripts', 'shop_manager_styles');
//if front end stylesheet needs to be added to cover admin bar:
//add_action('wp_enqueue_scripts', 'shop_manager_styles' ) ;
function shop_manager_styles() {
$user = wp_get_current_user() ;
//uncomment following and remove next if not confined to admin
//if ( $user && in_array( 'shop_manager', $user->roles ) ) {
if ( in_array( 'shop_manager', $user->roles ) ) {
//time() as stylesheeet version to help bust caching - may not be necessary but doesn't hurt:
wp_enqueue_style(
'shop_manager_styles', get_stylesheet_directory_uri()
. '/css/shop_manager_styles.css', array(), time()
);
}
}
...以及完全隐藏订单状态标签和菜单的css,以及shop_order子页面中的相关列:
/** HIDE ORDER STATUS LABEL, SELECTION MENU IN ORDER EDIT
* AND RELATED COLUMNS IN shop_order SUB-PAGE
*/
.wc-order-status,
.column-order_status,
.column-wc_actions {
display: none;
}
您可以将其保存在新的 shop_manager_styles.css 中的主题 css 文件夹中。
现在,您可能需要向商店经理显示订单状态,但他们无法对其进行编辑。这也可以通过 CSS 实现,如果也是(甚至更多)一个杂项的话。可能是您的安装中有其他特性会阻止上述代码或它的最小定制变体工作,但是,即使它比通过函数删除选项不太干净,这种事情通常会在紧要关头工作。
(已编辑以提供 选项 以在前端添加样式表 - 以防相关选项出现在管理栏中,否则无需排队额外的非管理脚本。)