Remove WordPress backend admin menu based on user role


The wordpress function ‘current_user_can’ decides the user capabilities.
You can check a list of capabilities here.

        if ( !current_user_can('remove_users') ) {
        function remove_menus () {
        global $menu;
            $restricted = array(__('Appearance'));
            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');
    } //ENDIF

Latest Comments

Leave a Reply

comment on this article