Get User Roles In WordPress

$user = get_userdata( $user->ID );
$capabilities = $user->{$wpdb->prefix . 'capabilities'};

if ( !isset( $wp_roles ) )
$wp_roles = new WP_Roles();

foreach ( $wp_roles->role_names as $role => $name ) {

if ( array_key_exists( $role, $capabilities ) )
echo $role;
}

Is user online

<?php
function omega_is_displayed_user_online(){
$member_id = bp_displayed_user_id();
if (bp_has_members('user_id=0&type=online')) :
while (bp_members()) : bp_the_member();
if($member_id == bp_get_member_user_id()) return true;
endwhile;
endif;
}

function omega_is_user_online($user_id){
if (bp_has_members('user_id=0&type=online')) :
while (bp_members()) : bp_the_member();
if($user_id == bp_get_member_user_id()) return true;
endwhile;
endif;
}
?>

Welcome User Msg in Admin Nav Bar

function add_welcome() {
global $current_user;
get_currentuserinfo();
$author = $current_user->display_name;
if ( is_user_logged_in() ) {
echo "<li class="welcome">" . bp_author_avatar() . "Welcome <strong>" . $author . "</strong></li>";
} else {
echo "<li class="welcome">Welcome <strong>Guest</strong></li>";
}
}

add_action( 'bp_adminbar_menus', 'add_welcome', 15 );