0

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;
    get_currentuserinfo();

    if($current_user->user_level < 10)
    {
        $restricted = array(__('Pages'),
                            __('Media'),
                            __('Links'),
                            __('Custom Post Name'),
                            __('Comments'),
                            __('Appearance'),
                            __('Plugins'),
                            __('Users'),
                            __('Tools'),
                            __('Settings'),
                            __('Posts'),
                            __('Produkter'),
                            __('Kontrolpanel'),

        );
        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?

1
  • 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
    Commented Mar 10, 2014 at 12:02

1 Answer 1

0

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');
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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