Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove admin bar links
add_action( 'wp_before_admin_bar_render', 'rf_remove_toolbar_links' );
function rf_remove_toolbar_links() {
// this function removes admin bar links for all users EXCEPT for user 1
global $wp_admin_bar;
$theuserid = get_current_user_id();
if ($theuserid != 1) {
$wp_admin_bar->remove_menu('themes'); // subitem themes
$wp_admin_bar->remove_menu('customize'); // subitem customize
$wp_admin_bar->remove_menu('widgets'); // subitem widgets
$wp_admin_bar->remove_menu('background'); // subitem background
$wp_admin_bar->remove_menu('ddw-gravityforms-toolbar'); // Gravity Forms Extended Toolbar
// $wp_admin_bar->remove_menu('w3tc'); // Total Cache
// $wp_admin_bar->remove_menu('comments'); // Comment count
$wp_admin_bar->remove_menu('wpseo-menu'); // Wordpress SEO Menu
$wp_admin_bar->remove_menu('ghooks'); // Visual Hooks Guide
$wp_admin_bar->remove_menu('new-media'); // Add new subitem – media
$wp_admin_bar->remove_menu('new-link'); // Add new subitem – link
$wp_admin_bar->remove_menu('new-user'); // Add new subitem – user
$wp_admin_bar->remove_menu('ddw-genesis-admin-bar'); // Genesis menu
$wp_admin_bar->remove_menu('plugin-toggle'); // Plugin Toggle plugin
// the code below should echo the admin bar boxes, so that you can see how to remove others
echo '<pre>';
echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment