Skip to content

Instantly share code, notes, and snippets.

@jjmontalban
Last active November 12, 2022 10:05
Show Gist options
  • Select an option

  • Save jjmontalban/0db568ac49cc42265262e69c871a2e9e to your computer and use it in GitHub Desktop.

Select an option

Save jjmontalban/0db568ac49cc42265262e69c871a2e9e to your computer and use it in GitHub Desktop.
Menús de administración que SÍ se ven - El resto desaparecen
/*
* @snippet Menús de administración que sí se ven - El resto desaparecen
* @author https://ayudawp.com/ocultar-menus-admin/
**/
if (!current_user_can( 'administrator' )) {
add_action('admin_init', 'ayudawp_admin_init');
}
function ayudawp_admin_init()
{
// Menús que se quedan
$menus_to_stay = array(
// Entradas
'edit.php?post_type=product',
);
foreach ($GLOBALS['menu'] as $key => $value) {
if (!in_array($value[2], $menus_to_stay)) remove_menu_page($value[2]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment