Created
May 1, 2014 21:32
-
-
Save jonschr/1a188bfd8f5956af55e5 to your computer and use it in GitHub Desktop.
Remove admin bar links
This file contains 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
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>'; | |
print_r($wp_admin_bar); | |
echo '</pre>'; | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment