Adding and Removing WordPress Admin Bar Items

For freelancers, progammers and designers, we always would want that our site turn-overs be smooth.  Especially with wordpress websites.  Though our clients have access to an admin account, we let them use an account with minimized menus and navigation to lessen the possibility of the client messing up with templates and/or plugins let alone with wordpress core files.

For simplicity in Adding and Removing WordPress Admin Bar Items, here are two basic functions (yes functions that we can insert into our client’s function.php file in within their template).

1) This one removes items from the admin bar, we have programmed ours to remove certain items should certain usernames be used to log in.

add_action( 'admin_bar_menu', 'remove_admin_bar_items', 999 );
function remove_admin_bar_items( $wp_admin_bar )
{
$current_user = wp_get_current_user();
$loggedinuser=$current_user->user_login;
if (($loggedinuser=="admin") || ($loggedinuser=="marketing") || ($loggedinuser=="mis"))
{
$wp_admin_bar->remove_node( 'wp-logo' );
$wp_admin_bar->remove_node( 'comments' );
$wp_admin_bar->remove_node( 'new-etn_menu' );

   }else{
$wp_admin_bar->remove_node( ‘wp-logo’ );
$wp_admin_bar->remove_node( ‘comments’ );
$wp_admin_bar->remove_node( ‘new-content’ );
   }

}

resource: http://churchm.ag/remove-menu-items-from-wordpress-3-3-admin-bar/

2) This one adds items to the admin bar, specifically under the “Howdy” portion.

add_action('admin_bar_menu', 'add_items',  100);
function add_items($admin_bar)
{
   $args = array(
   'id'    => 'my-item',
   'title' => 'Support',
   'href'  => 'http://www.etnmultimedia.com/support/',
   'parent' => 'user-actions',
   'meta'  => array('title' => __('Support  @ ETN Multimedia'),'target' =>__('_blank'))
   );
   $admin_bar->add_menu( $args);
}

resource : http://blog.rutwick.com/add-items-anywhere-to-the-wp-3-3-admin-bar

Alphonse

I tried reinventing myself and succeeded in becoming a web and wordpress designer and developer. This has become my passion...