Skip to content

Instantly share code, notes, and snippets.

@UmeshSingla
Created June 7, 2013 07:59
Show Gist options
  • Save UmeshSingla/5727702 to your computer and use it in GitHub Desktop.
Save UmeshSingla/5727702 to your computer and use it in GitHub Desktop.
Wordpress- Custom Message in Admin Bar
<?php
/* Custom Info Admin Bar */
function rtp_role_info() {
global $wp_admin_bar, $wpdb;
$message = '';
if(current_user_can('basic_contributor')){
$message = "Basic User";
}elseif(current_user_can('premium')){
$message = "Premium User";
}
elseif(current_user_can('primary-advertiser')){
$message = "Primary Advertiser";
}
elseif(current_user_can('advertiser')){
$message = "Advertiser";
}elseif(current_user_can('secondary-advertiser')){
$message = "Secondary Advertiser";
}elseif(is_super_admin()){
$message = "Administrator";
}
if ( !is_admin_bar_showing() )
return;
/* Add the main siteadmin menu item */
if(!empty($message)){
$wp_admin_bar->add_menu( array( 'id' => 'role_message', 'title' => __( 'You are logged in as a '.$message, 'textdomain' ), 'href' => FALSE ) );
}
}
add_action( 'admin_bar_menu', 'rtp_role_info', 1000 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment