menu remove for clients (5 posts)

  1. moneyz
    Posted 3 years ago #

    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

  2. moneyz
    Posted 3 years ago #

    any one help me

  3. bcworkz
    Posted 3 years ago #

    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.

  4. moneyz
    Posted 3 years ago #

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

  5. bcworkz
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.