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
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 5 replies, has 2 voices.
Last updated by 7 years, 6 months ago.
Assisted by: Christian Cox.