Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove menus for specific users in Wordpress
<?php
add_action( 'admin_menu', 'remove_menus' );
function remove_menus() {
global $menu;
global $submenu;
// echo '<pre>';
// print_r($menu);
// print_r($submenu);
// echo '</pre>';
// If you're not the site creator
// Hide some menus
if ( wp_get_current_user()->ID != 1 ) {
unset($menu[25]); // Removes 'Comments'.
unset($menu[65]); // Removes 'Plugins'.
unset($submenu['index.php'][10]); // Removes 'Updates'.
unset($submenu['themes.php'][5]); // Removes 'Themes'.
unset($submenu['themes.php'][6]); // Removes 'Customize'.
unset($submenu['themes.php'][11]); // Removes 'Editor'.
}
}
?>
<?php
add_action( 'admin_menu', 'rename_posts_menu' );
// echo '<pre>';
// print_r($menu);
// print_r($submenu);
// echo '</pre>';
function rename_posts_menu() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News Items';
$submenu['edit.php'][10][0] = 'Add News Item';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.