How to Remove Menus From the WordPress Dashboard

The WordPress codex is full of fun little things that you can experiment with. Have you ever wanted to remove a menu page from the WordPress dashboard? Perhaps you’re building a site for a client who gets confused by the settings menu. Blow the dust off of your handy codex and check out the function references for removing menu pages.

Here’s what you’re looking for:

1
<?php remove_menu_page( $menu_slug ) ?>

Replace the menu slug with the name of the php script for the menu item you want to remove.

Here’s a quick example. Let’s say you want to remove the posts menu. Who needs to write posts?

Just for kicks, let’s remove the settings menu, too. Here’s the before and after:

The quick and dirty way to do this one is to add it to your theme’s functions.php file, but that’s only if you’re feeling like a lazy goose. The best way to add this type of modification is to create a functionality plugin. Don’t worry it’s very easy. Just open a blank text file and add a little information about your plugin and then your code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
/*
Plugin Name: Remove Settings and Posts Menu
Description: Just don't want my settings menu anymore and I don't want to write any posts - what's the big deal?
Version: 0.1
License: GPL
Author: Sarah Gooding
Author URI: http://untame.net
*/

    add_action( 'admin_menu', 'my_remove_menu_pages' );

    function my_remove_menu_pages() {
        remove_menu_page('options-general.php');
        remove_menu_page('edit.php');           
    }
?>

Save this as remove-menu.php or whatever you want to name it. Then upload it to wp-content/plugins.

Last step: Don’t forget to activate your little plugin. You’ll find it among your inactive plugins, ready to activate:

That was easy, wasn’t it? Please be advised that this only removes the items from the menu but does not prevent a user from accessing those pages, should he know where they are located. For that you’d be better off using a more comprehensive option that limits users based on roles and capabilities.

Before turning to the plugin repository, you may want to have a little fun exploring the codex. You might find exactly what you need to create your own quick plugin.

Comments (10)

  1. Does this work only for the main menu items? I edited it for just the Tools / Import item (import.php), and it seemed to have no effect. The menu item was still there and import.php was accessed with it.

  2. Hi,
    This post is very valuable, thank you. I applied it.
    But I have a more question;
    how can I remove contact form7 from dashboard, because it is like this;
    ……com/wp-admin/admin.php?page=wpcf7
    what have I to write to remove_menu_page(‘?????’);
    Thanks for your cooperation.
    Regards

  3. What about a plugin to hide menu options (theme, editor, plugins etc )from clients and limit users based on roles and capabilities.

    Now that would be a great plugin:)

    Maybe included into your white label branding plugin.

  4. Hi Sarah
    I found another tutorial which gave:

    // Remove Settings menu item for all but Superadmin
    function wptutsplus_remove_settings_menu_item() {
    $user = wp_get_current_user();
    if ( $userdata->ID != 1 ) {
    remove_menu_page( ‘options-general.php’ );
    }
    }
    add_action( ‘admin_menu’, ‘wptutsplus_remove_settings_menu_item’ );

    but the Settings page disappears for all users including user with ID = 1.

    Any suggestions?

Participate