Last active
October 22, 2020 14:13
-
-
Save zorem/10b23b77f8b9a2f693043731e8939b3a to your computer and use it in GitHub Desktop.
Remove WooCommerce Dashboard Status, reports and analytics for shop manager user role
This file contains 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 | |
/* | |
* https://www.zorem.com/hide-sales-data-from-the-woocommerce-shop-manager-role/ | |
* | |
* Remove WooCommerce Dashboard Status for shop manager | |
*/ | |
function remove_dashboard_widgets() { | |
if ( current_user_can( 'shop_manager' ) ) { | |
// remove WooCommerce Dashboard Status | |
remove_meta_box( 'woocommerce_dashboard_status', 'dashboard', 'normal' ); | |
} | |
} | |
add_action( 'wp_user_dashboard_setup', 'remove_dashboard_widgets', 20 ); | |
add_action( 'wp_dashboard_setup', 'remove_dashboard_widgets', 20 ); | |
/* | |
* Remove WooCommerce reports for shop manager | |
* Remove analytics for shop manager | |
*/ | |
function zorem_remove_wc_reports() { | |
if ( current_user_can( 'shop_manager' ) ) { | |
remove_submenu_page( 'woocommerce', 'wc-reports' ); | |
remove_menu_page( 'wc-admin&path=/analytics/overview' ); | |
remove_submenu_page( 'woocommerce', 'wc-admin' ); | |
} | |
} | |
add_action('admin_menu', 'zorem_remove_wc_reports', 110); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment