Feel free to modify is as necessary.
► Tip: you can print_r($menu) to see what to keep.
add_action('admin_menu', function () {
if (current_user_can('administrator')) {
return;
}
/**
* Keep only specific menu items and remove all others
*/
global $menu;
$hMenu = $menu;
foreach ($hMenu as $nMenuIndex => $hMenuItem) {
if (in_array($hMenuItem[2], array(
'index.php',
'edit.php?post_type=product',
))
) {
continue;
}
unset($menu[$nMenuIndex]);
}
}
No comments:
Post a Comment