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?

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:

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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_admin_reports', 'restricts_wc_reports_tabs', 10, 1 ); | |
function restricts_wc_reports_tabs( $reports ) { | |
if ( current_user_can( 'manage_woocommerce' ) ) { | |
// do not restrict WooCommerce admin | |
return $reports; | |
} | |
unset( $reports['orders'] ); | |
unset( $reports['customers'] ); | |
// unset( $reports['stock'] ); | |
unset( $reports['taxes'] ); | |
return $reports; | |
} | |
// end of restricts_wc_reports_tabs() |