I want to remove certain dashboard menu times for a specific user. Now this menu consist of plugin menu items as well. One particular plugin I want to hide from the user is Contact Form 7.
Here is the code added to the functions.php file to hide the menu items:
function remove_menus()
{
global $menu;
global $current_user;
get_currentuserinfo();
if($current_user->user_login == 'brian')
{
$restricted = array(__('Media'),
__('Links'),
__('Pages'),
__('Comments'),
__('Appearance'),
__('Plugins'),
__('Users'),
__('Tools'),
__('Settings'),
__('WPCF7') //this does not work
);
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', 'remove_menus');
Now everything listed in the code above here is hidden, except for the Contact Form 7 Plugin menu. How do I call the correct plugin name?
Thanks
Here is the code you need:
Or if you want to retain your own code, use this:
I changed WPCF7 to Contact in the array.