Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Last active December 19, 2015 02:58
Show Gist options
  • Select an option

  • Save raphaelchaib/5886416 to your computer and use it in GitHub Desktop.

Select an option

Save raphaelchaib/5886416 to your computer and use it in GitHub Desktop.
WordPress: Remove links from WordPress Admin Bar
<?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