WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made some restrictions on other user roles than the administrator. I've made it because I use WooCommerce.

I have added the following code to my themes functions.php file, and it works fine.

function remove_menus()
    global $menu;
    global $current_user;

    if($current_user->user_level < 10)
        $restricted = array(__('Pages'),
                            __('Custom Post Name'),

        end ($menu);
        while (prev($menu)){
            $value = explode(' ',$menu[key($menu)][0]);
            if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
        }// end while
    }// end if
add_action('admin_menu', 'remove_menus');

I want to hide "WooCommerce -> Settings", but I cannot figure out how to make it happen in the above code? Can someone help me?

share|improve this question
This highly depends how and where the menu is registered. You'll have to dig into WooCommerce core, file an edit and add this info to your question. – kaiser Mar 10 '14 at 12:02

Actually its very simple ex:

// only administrator
if ( ! current_user_can('manage_options') ) {
    add_action( 'admin_menu', 'remove_woocommerce_menu_pages', 999 );
    function remove_woocommerce_menu_pages() {
        remove_submenu_page('woocommerce', 'woocommerce_settings');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.