Support » Plugins and Hacks » Hacks » menu remove for clients

menu remove for clients

  • i’m using this code for menu remove function

    function remove_menus () {
    global $menu;
    		$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
    		end ($menu);
    		while (prev($menu)){
    			$value = explode(' ',$menu[key($menu)][0]);
    			if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
    add_action('admin_menu', 'remove_menus');

    this code working fine but i want remove admin pages like jatpack page remove this url like this how to remove to menu

Viewing 4 replies - 1 through 4 (of 4 total)
  • any one help me

    You can use code similar to yours wrapped in a if(!current_user_can('some_capability')) block instead of the if(in_array()). Essentially means if the current user does NOT have a capability, remove some menu element. You just need to determine the correct $menu key to unset.

    i want to remove dashboard sidebar menu not user role it’s for admin role

    Yes, you will be unsetting a menu key based on a particular user’s lack of capability instead of matching a value in an array. I’m suggesting you tweak your existing code. None of this has any effect on assigned roles.

    If you don’t understand what a particular function does, you are right to question it, but good explanations are available in the Codex and php.net.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘menu remove for clients’ is closed to new replies.