-
-
Save pietromalerba/248b1579df9d09da8776 to your computer and use it in GitHub Desktop.
Remove menu for specific users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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'. | |
| } | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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