Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
Share
LinkBack Thread Tools
Old 08-04-2012, 07:36 PM   #1
WordPress Developer
War Room Member
 
Jeremy Lebre's Avatar
 
Join Date: Jul 2012
Posts: 27
Thanks: 4
Thanked 4 Times in 3 Posts
Default Remove some menus in WordPress

You can remove some menus of the WordPress interface by adding
the following code to the functions.php file of your theme:

PHP Code:
function remove_menu() {
global 
$menu;
unset(
$menu[2]); /* remove the menu "Dashboard" */
unset($menu[5]); /* remove the menu "Posts" */
unset($menu[10]); /* remove the menu "Medias" */
unset($menu[15]); /* remove the menu "Links" */
unset($menu[20]); /* remove the menu "Pages" */
unset($menu[25]); /* remove the menu "Comments" */
unset($menu[60]); /* remove the menu "Appearance" */
unset($menu[65]); /* remove the menu "Plugins" */
unset($menu[70]); /* remove the menu "Users" */
unset($menu[75]); /* remove the menu "Tools" */
unset($menu[80]); /* remove the menu "Settings" */
}

add_action('admin_head''remove_menu'); 
If you prefer to keep one of these menus, simply delete the
corresponding line of code.

Jeremy Lebre is offline   Reply With Quote
Old 08-04-2012, 07:40 PM   #2
Warrior Member
 
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Remove some menus in WordPress

can we remove specific menus for specific roles?
caballus is offline   Reply With Quote
Old 08-04-2012, 08:00 PM   #3
WordPress Developer
War Room Member
 
Jeremy Lebre's Avatar
 
Join Date: Jul 2012
Posts: 27
Thanks: 4
Thanked 4 Times in 3 Posts
Default Re: Remove some menus in WordPress

Yes, like this:

PHP Code:
function remove_menu() {
global 
menu;
if (!
current_user_can('manage_options')) { unset(menu[25]); } /* remove the menu "Comments" if the user is not an admin */
}

add_action('admin_head''remove_menu'); 
Add a $ just before menu.

Jeremy Lebre is offline   Reply With Quote
Old 08-05-2012, 08:12 PM   #4
Active Warrior
 
Altin's Avatar
 
Join Date: Jul 2012
Location: Albania
Posts: 70
Thanks: 25
Thanked 9 Times in 8 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
Default Re: Remove some menus in WordPress

Isn't it bad to use specific menu id-s? What if we add or remove menus from backend? You will still need to edit the actual php code then. Now very flexible...

Altin is offline   Reply With Quote
Old 08-05-2012, 10:19 PM   #5
WordPress Developer
War Room Member
 
Jeremy Lebre's Avatar
 
Join Date: Jul 2012
Posts: 27
Thanks: 4
Thanked 4 Times in 3 Posts
Default Re: Remove some menus in WordPress

WordPress developers won't change the numeric keys of the current menus.

Jeremy Lebre is offline   Reply With Quote
Old 08-05-2012, 11:58 PM   #6
HyperActive Warrior
War Room Member
 
Azlan's Avatar
 
Join Date: Sep 2008
Location: Malaysia
Posts: 195
Thanks: 9
Thanked 13 Times in 13 Posts
Contact Info
Send a message via Yahoo to Azlan Send a message via Skype™ to Azlan
Default Re: Remove some menus in WordPress

Thank for this post it helps a lot

New WSO - Coming Soon...
Azlan is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Bookmarks

Tags
menus, remove, wordpress

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 03:38 AM.