Skip to content

Instantly share code, notes, and snippets.

@benmay
Created March 6, 2013 05:10
Show Gist options
  • Save benmay/5096884 to your computer and use it in GitHub Desktop.
Save benmay/5096884 to your computer and use it in GitHub Desktop.
<?php
add_action ( 'admin_init', 'clean_up_admin_menu' );
function clean_up_admin_menu ()
{
global $current_user, $menu;
$u = $current_user->user_login;
// If user isn't logged in. (fix for wp-admin/admin-ajax.php
if( ! $u )
return;
// If it's admin or Alyte (admin) then leave all in tact.
if( $u == 'admin' || $u == 'alyte Ben' || $u == 'alyte Paul' )
return;
$exclude = array();
array_push( $exclude, 'Posts' );
array_push( $exclude, 'Comments' );
array_push( $exclude, 'Tools' );
array_push( $exclude, 'Forms' );
array_push( $exclude, 'Profile' );
array_push( $exclude, 'Links' );
array_push( $exclude, 'Plugins' );
array_push( $exclude, 'Settings' );
array_push( $exclude, 'VaultPress' );
foreach($menu as $mId=>$menuArray){
$tmp = explode(' ', $menuArray[0]);
if( in_array( $tmp[0] , $exclude ) )
unset($menu[$mId]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment