Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odirlon/0e7517476366982fc63a52259a55838e to your computer and use it in GitHub Desktop.
Save odirlon/0e7517476366982fc63a52259a55838e to your computer and use it in GitHub Desktop.
Remove WooCommerce submenu items for Shop Managers
<?php
/*
Don't copy the opening php tag
*/
/*
Removes submenu items from WooCommerce menu for 'Shop Managers'
available submenu slugs are:
wc-addons - the Add-ons submenu
wc-status - the System Status submenu
wc-reports - the Reports submenu
edit.php?post_type=shop_order - the Orders submenu
edit.php?post_type=shop_coupon - the Coupons submenu
Shop Managers lack the capability of 'update_core', so remove based on that capability
*/
function wooninja_remove_items() {
$remove = array( 'wc-settings', 'wc-status', 'wc-addons', );
foreach ( $remove as $submenu_slug ) {
if ( ! current_user_can( 'update_core' ) ) {
remove_submenu_page( 'woocommerce', $submenu_slug );
}
}
}
add_action( 'admin_menu', 'wooninja_remove_items', 99, 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment