Last active
December 19, 2015 02:58
-
-
Save raphaelchaib/5886416 to your computer and use it in GitHub Desktop.
WordPress: Remove links from WordPress Admin Bar
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 | |
| // The follow will remove the updates, comments, new content and performance links from the admin bar if the user isn't the admin user. | |
| // On most WordPress blogs the admin user has the User ID of 1 so you can apply the following snippet. | |
| function remove_admin_bar_links() { | |
| global $wp_admin_bar, $current_user; | |
| if ($current_user->ID != 1) { | |
| $wp_admin_bar->remove_menu('updates'); // Remove the updates link | |
| $wp_admin_bar->remove_menu('comments'); // Remove the comments link | |
| $wp_admin_bar->remove_menu('new-content'); // Remove the content link | |
| $wp_admin_bar->remove_menu('w3tc'); // If you use w3 total cache remove the performance link | |
| $wp_admin_bar->remove_menu('my-account'); // Remove the user details tab | |
| } | |
| } | |
| add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment