WordPress remove menu items from wp-admin

I want that in wp-admin will be only Posts, Pages and Settings, it’s possible to remove al remaining Media, Plugins, Users, Tools etc.

This function remove only from dashboard remove_menu_page( 'upload.php' );

Related posts

Leave a Reply

2 comments

  1. Remove that menus from $restricted, that you want to prevent.

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

    Credit goes to hungred via wprecipes

  2. Since WordPress 3.1 you can better use remove_menu_page()

    add_action( 'admin_menu', 'prefix_remove_menu_pages' );
    function prefix_remove_menu_pages() {
        remove_menu_page('edit-comments.php');
        remove_menu_page('upload.php'); 
        remove_menu_page('tools.php');
        // Remove any item you want
      }
    }
    

    from the docs:

    Please be aware that remove_menu_pages would not prevent a user from accessing
    these screens directly. Removing a menu does not replace the need to
    filter a user’s permissions as appropriate.

    And for submenu items:

    To remove submenu items in the admin, use remove_submenu_page. Using
    remove_menu_page() will not work for submenu items.