Restrict selected WooCommerce reports

Admin menu item “WooCommerce->Reports” is protected by ‘view_woocommerce_reports’ user capability. User with this capability has access to WooCommerce reports page. This page contains several tabs: “Orders”, “Customers”, “Stock”, “Taxes”. Is it possible to restrict selected reports (tabs) for the selected role?

woocommerce reports tabs
WooCommerce reports tabs

Yes, it’s possible with a help of custom filter ‘woocommerce_admin_reports’. Let’s allow to user with ‘view_woocommerce_reports’ capability to view only “Stock’ reports. WooCommerce reports page will be shown this way:

woocommerce reports tabs restricted
Woocommerce reports tabs restricted

Add code below to the active theme `functions.php` file or set it as a Must Use plugin to `wp-content/mu-plugins/` folder to achieve this.

Share