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.










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
@ Wolly: done, I hope will be useful to see ... Very short snippet: Wordpress administrator?
But give it a less powerful account, right?
@ 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
[...] 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/ [...]
beautiful, then if you connect tiger admin plugin furi is also a nice graphics package for customers.
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?
I'm sorry, but where to put that code??
Thank you in advance
@ Peter:
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 ...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
@ Peter:
Sure, you can put it - of course - even in a Plugin already exists.
@ Peter:
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.
Enter a file. Htaccess file in the root will?