簡體   English   中英

在批量訂單面板上刪除或隱藏woocommerce上的“添加新”按鈕

[英]Remove or hide “add new” button on woocommerce on bulk order panel

我正在搜索很多這個,但我找不到我必須改變的文件。

我需要在wordpress / woocommerce儀表板上刪除或隱藏此按鈕,因為我不希望店鋪經理或其他用戶執行此操作。 這里有一些圖片來解釋我必須刪除的內容。

按鈕隱藏或刪除1

按鈕隱藏或刪除2

一個很好的選擇是添加一些自定義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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM