Mantas Kudeikis
Mantas Kudeikis

Reputation: 489

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

Upvotes: 1

Views: 4086

Answers (2)

user63457
user63457

Reputation: 681

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.

Upvotes: 2

david.binda
david.binda

Reputation: 1068

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

Upvotes: 2

Related Questions