Thread Starter
z
(@murenti)
To help you understand please see the code below.
/**
* Remove unwanted menus in dashboard
*/
function remove_menus () {
global $menu;
$restricted = array(__(”), __(‘jetpack’));
end ($menu);
while (prev($menu)){
$value = explode(‘ ‘,$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){unset($menu[key($menu)]);}
}
}
add_action(‘admin_menu’, ‘remove_menus’);
?>
Plugin Contributor
csonnek
(@csonnek)
Happiness Rocketeer 🚀
When you want to “remove unwanted menu” – in what context are you trying to remove it? Once I have that information, I’ll be better able to answer the question.
Thread Starter
z
(@murenti)
Hi,
Thank you for responding I do appreciate it 🙂
The details:
1) I am not a programmer but I dabble, sorry if I don’t get it the first time.
2) The code above references menu id and in this case “adminmenu”
3) It then hides the admin menu <div class=”wp-menu-name”>Dashboard</div>
4) If I place “Dashboard” into the following line $restricted = array(__(‘Dashboard’)); ….it Hides the “Dashboard” from the backend menu list on the left.
5) The problem is I want to also hide “Jetpack” menu in the same manner but when adding $restricted = array(__(‘Jetpack’)); …..the “Jetpack” menu item remains.
I am not sure why and was wondering if you might be able to or inclined to offer any help please? I also understand that this is not your plugin and you May ask me to speak to the plugin guy and I have only just thought of this, sorry. But if you can offer any easy suggestion to fix it now, I will be very grateful.
🙂 🙂 <—— 2 Really smiley faces
Plugin Contributor
csonnek
(@csonnek)
Happiness Rocketeer 🚀
Jetpack is “my plugin” so the question was asked in the correct place.
Is there a reason you’re not taking advantage of existing plugins that are doing exactly what you seek? This particular plugin will hide the Jetpack menu item (and all other menu items) if you choose:
https://ww.wp.xz.cn/plugins/admin-menu-editor/
Note: hiding the menu will remove your ability to configure and manage the settings in Jetpack and is not recommended.
If you want to hide menu items using your own code, I highly suggest studying that plugin to see how they’re doing it as we don’t advocate hiding menu items because those items provide functionality to your site’s backend.
I hope that clarifies things! Marking as resolved.
Thread Starter
z
(@murenti)
I love Jetpack but I wanted to manipulate the menu showing for each level of user login access.
The plugin you suggested is excellent, many thanks. I did not know it existed until you suggested it.
Thanks for your help.