3

I was searching a lot about this, but I can't find the file that I have to change.

I need to remove or hide this button on wordpress / woocommerce dashboard because I don't want shop manager or another users do this action. Here are some images to explain what I have to remove.

button to hide or remove 1

button to hide or remove 2

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Rocío SG
  • 51
  • 1
  • 6
  • You could try using a plugin such as Members to edit the `shop_manager` role to remove `publish_shop_orders` capability. Not sure if that would work though. – helgatheviking Sep 26 '17 at 17:11
  • I already try this, but it still shows up the button. The shop manager has permission to see order details, but not to editing them and i don't want he or another user add orders from wordpress dashboard. Can I do it with php code? – Rocío SG Sep 26 '17 at 17:22

2 Answers2

2

A good alternative is to add some custom CSS to hide "Add Order" buttons targeting conditionally user roles capabilities, in a custom function hooked in admin_head action hook:

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;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and perfectly works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
2

You can try this code

add_filter( 'woocommerce_register_post_type_shop_order','your_function_name' );
function your_function_name($fields) {
        $fields['capabilities'] = array(
            'create_posts' => false,
          );
        return $fields;
    }
MakeWebBetter
  • 463
  • 3
  • 5