Change WordPress user roles and capabilities Forums How to or FAQ Restrict Role from Processing Refunds in WooCommerce Reply To: Restrict Role from Processing Refunds in WooCommerce

#2726
Vladimir
Keymaster

Hi,

The only way to hide “Refunds” button from order edit form is to change HTML page CSS via JavaScript. Add code below to the active theme functions.php file or setup it as a must-use plugin. It is executed for the ‘orders-manager’ role only. Replace it with you own role ID.


add_action('admin_head', 'hide_wc_refund_button');

function hide_wc_refund_button() {

    global $post;

    if (!current_user_can('orders-manager')) {
        return;
    }
    if (strpos($_SERVER['REQUEST_URI'], 'post.php?post=') === false) {
        return;
    }

    if (empty($post) || $post->post_type != 'shop_order') {
        return;
    }
?>
    <script>
      jQuery().ready(function () {
            jQuery('.refund-items').hide();
        });
    </script>
    <?php

}