[英]Woocommerce / Wordpress - Add button to Order / Product Page on Admin Panel
[英]Remove or hide “add new” button on woocommerce on bulk order panel
我正在搜索很多這個,但我找不到我必須改變的文件。
我需要在wordpress / woocommerce儀表板上刪除或隱藏此按鈕,因為我不希望店鋪經理或其他用戶執行此操作。 這里有一些圖片來解釋我必須刪除的內容。
一個很好的選擇是添加一些自定義CSS來隱藏定位用戶角色功能的“添加訂單”按鈕,這個按鈕位於admin_head
動作鈎子中的自定義函數中:
add_action( 'admin_head', 'my_custom_admin_styles' );
function my_custom_admin_styles() {
// HIDE "New Order" button when current user don't have 'manage_options' admin user role capability
if( ! current_user_can( 'manage_options' ) ):
?>
<style>
.post-type-shop_order #wpbody-content > div.wrap > a.page-title-action{
display: none !important;
}
</style>
<?php
endif;
}
代碼放在活動子主題(或主題)的function.php文件中,或者放在任何插件文件中。
經過測試,完美無缺。
您可以嘗試此代碼
add_filter( 'woocommerce_register_post_type_shop_order','your_function_name' );
function your_function_name($fields) {
$fields['capabilities'] = array(
'create_posts' => false,
);
return $fields;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.