Last active
October 29, 2016 00:50
-
-
Save acanza/9c4bd114cc1f8c5b328c to your computer and use it in GitHub Desktop.
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
//* Crea rol empleado de tienda | |
add_action( 'init', 'add_shop_staff_rol' ); | |
function add_shop_staff_rol(){ | |
$shop_role = get_role( 'shop_manager' ); | |
add_role( 'shop_staff', __( 'Empleado de tienda', 'woocommerce' ), $shop_role->capabilities ); | |
} | |
//* Oculta algunas secciones del panel de ajustes de WooCommerce al rol de usuario 'shop_staff' | |
function hide_wc_menu_items() { | |
global $current_user; | |
//* Get the current user role | |
$user_roles = $current_user->roles; | |
$user_role = array_shift($user_roles); | |
//* Set up the sections list to hide | |
$remove = array( 'wc-settings', 'wc-status', 'wc-addons', ); | |
if ( 'shop_staff' == $user_role ) { | |
remove_submenu_page( 'woocommerce', 'wc-settings' ); | |
remove_submenu_page( 'woocommerce', 'wc-status' ); | |
remove_submenu_page( 'woocommerce', 'wc-addons' ); | |
remove_submenu_page( 'woocommerce', 'edit.php?post_type=shop_coupon' ); | |
remove_submenu_page( 'edit.php?post_type=product', 'product_attributes' ); | |
remove_submenu_page( 'edit.php?post_type=product', 'edit-tags.php?taxonomy=product_shipping_class&post_type=product' ); | |
} | |
} | |
add_action( 'admin_menu', 'hide_wc_menu_items', 99, 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment