Skip to content

Instantly share code, notes, and snippets.

@intelliweb
Created April 9, 2013 03:09
Show Gist options
  • Save intelliweb/5342633 to your computer and use it in GitHub Desktop.
Save intelliweb/5342633 to your computer and use it in GitHub Desktop.
WP: remove menu items from WP admin
<?php
function intw_remove_menus() {
global $menu;
global $current_user;
get_currentuserinfo();
if($current_user->user_login != 'webmaster') {
$restricted = array(
__('Posts'),
__('Links'),
__('Comments'),
__('Appearance'),
__('Plugins'),
__('Users'),
__('Tools'),
__('Settings')
);
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}// end while
}// end if
}
add_action('admin_menu', 'intw_remove_menus');
function intw_hide_menus() {
global $current_user;
get_currentuserinfo();
if($current_user->user_login != 'webmaster') {
?>
<style>
#toplevel_page_headway,
#toplevel_page_pluginbuddy_backupbuddy{
display:none;
}
</style>
<?php
}
}
add_action('admin_head', 'intw_hide_menus');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment