Wordpress: remove the menu administration

It can be useful at times, "obscure" some WordPress administration menu, especially if you developed a site / blog for a client and do not want to allow access to particularly sensitive features. There are already plugins that perform this function but, for personal control and complete, we see how this feature works in detail.
As always we use the very useful Action provided by WordPress, in this case admin_menu . Using the global variable $menu can access the administration menu list. We can find the menu to "eliminate" in two ways: through the label or through the link that it points to (see annotated games in the example below). In this example are "blacked out" menu items Design, Settings, and Plugins:

1
2
3
4
5
6
7
8
9
10
11
12
13
remove_menu_item function () {
; global $ menu;
/ / By label
array ( 'Design' , 'Impostazioni' , 'Plugins' ) ; Removes $ = array ('Design', 'Settings', 'plugins');
/ / By link
/ / Removes $ = array ('themes.php', 'options-general.php', 'plugins.php');
$removes as $todel ) foreach ($ as $ Removes todel)
$menu as $key => $sm ) if ( $sm [ 0 ] == $todel ) { unset ( $menu [ $key ] ) ; break ; } foreach ($ menu as $ key => $ level) if ($ sm [0] == $ todel) { unset ($ menu [$ key]) break;}
/ / By link
/ / Foreach ($ menu as $ key => $ level) if ($ sm [2] == $ todel) {unset ($ menu [$ key]) break;}
}
/ /
, 'remove_menu_item' ) ; add_action ('admin_menu', 'remove_menu_item');

The use of links as a key to the removal ( $sm[2] commented in the code share in surprise), is useful when you are not sure of the language - localization - with which you installed WordPress. With this technique, however, the menu is removed only at the interface, so you can still access the site via a direct link.

12 comments to "Wordpress: remove the menu administration"

  1. November 1, 2008 Wolly :

    Very nice tutorial.
    We are often asked on the support forum how to remove menus' But on the bulletin board user level.
    If I add the control to the user level and if we allow the code to post this in the wiki.
    hello

  2. November 3, 2008 camu :

    But give it a less powerful account, right? :)

  3. November 3, 2008 Wolly :

    @ Camu's not a question of power of the account, there are some who would like to see who writes on their blog to write only the part and can not even see anything else comments.
    And 'their need, right or wrong, and since they ask many prefer to give them a solution.
    hello

  4. November 7, 2008 The Wolly "A page" post-new "entry for employees ..."

    [...] The new version of wordpress 2.7 has a page of the genre. The problem then is to inhibit all the rest but you can try these scripts udolog http://www.undolog.com/2008/11/01/wordpress-rimuovere-i-menu-dellamministrazione/ [...]

  5. December 6, 2008 alessio:

    beautiful, then if you connect tiger admin plugin furi is also a nice graphics package for customers.

  6. February 8, 2009 split :

    Sorry but I can not get by with the code ...
    I described this need to limit the blog post. Being a club everyone wants a piece of access, but of course I have to limit the intervention to the blog.
    I thought with a specific plugin, but I can not find the code and I realized that it acts at the admin menu ... Tips please?

  7. November 23, 2009 Peter :

    I'm sorry, but where to put that code??
    Thank you in advance

  8. November 23, 2009 Giovambattista Fazioli :

    @ Peter:

    I'm sorry, but where to put that code??

    You can insert it in the file functions.php , displayed in the folder of your active theme. Alternatively, if you are developing your own plugins, in its code. In practice, the important thing is that this code is executed at least once ... : D

  9. November 24, 2009 Peter :

    Thanks, you also put it in a function if you existing plugins?
    No, because I am creating a web hosting service in which a person may require perosna's very own blog based on WordPress (mu NOT) I would like to hide from the menu button that sends the administrative management of plugins EasyAdsense so that the 'user can not change the advertising at will.
    Do you know if you can? Or in which file to put that code without protein is deleted when it is updated wordpress, plugins or templates?
    Thanks again, expect answers

  10. November 25, 2009 Giovambattista Fazioli :

    @ Peter:

    Thanks, you also put it in a function if you existing plugins?

    Sure, you can put it - of course - even in a Plugin already exists.

    @ Peter:

    Do you know if you can? Or in which file to put that code without protein is deleted when it is updated wordpress, plugins or templates?

    This procedure is used to conceal some of the controls for any user who works in the backend of WordPress. For updates, however, need to find a "place" that surely can not be overwritten by updates. WordPress MU, for example, will simplify the task as it has the ability to "impose" Plugins to all the sub-blog.
    Normal installation of WordPress, where you can update the version, update the theme (and then overwrite the file functions.php) and update the plugin (and then delete them or disable them) do not know where to position the code ... I think you and I to know.

  11. November 25, 2009 Peter :

    Enter a file. Htaccess file in the root will?

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Stop SOPA