Alex Cespedes
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Removing access to WooCommerce Settings for a Custom User Role
Started by: Alex Cespedes
in: Toolset Professional Support
Problem: I have a custom user role that has access to the WooCommerce admin menu. I would like to remove the "Settings" and "Extensions" submenu items from the WooCommerce admin menu for this user role. Solution: Add the following code to your functions.php file: add_action( 'admin_menu', 'remove_menu_pages', 999); function remove_menu_pages() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); if($user_role == "user-role-slug") { $remove_submenu = remove_submenu_page('woocommerce', 'wc-settings'); $remove_submenu = remove_submenu_page('woocommerce', 'wc-addons'); } } Edit "user-role-slug" to use the proper slug for your custom user role, and add or remove $remove_submenu lines to remove the desired page submenus. The slugs for each page can be found in wp-admin URLs as shown in the attached screenshot below. Relevant Documentation: https://codex.wordpress.org/Function_Reference/remove_submenu_page |
2 | 6 | 7 years, 6 months ago |