Generally it is not a good idea to use bp_has_members inside a bp_has_members loop.
It probably won’t work, well maybe in BP 1.6.
Anyhow, you could try:
`
$user_id=bp_get_member_user_id();
if ( bp_has_members( ‘type=online&populate_extras=0&include=’.$user_id))
`
I basically use the approach below to check ‘online’ within members-loop:
(why? don’t recall, but probably because the above approach didn’t work )
`
// put this at the top of members-loop
$keep_checking_online = true;
function check_user_online_str($get_active_str){
$needles = array(‘hour’, ‘day’, ‘month’, ‘week’, ‘year’);
foreach ($needles as $needle) {
if (stripos($get_active_str, $needle)!==FALSE) return false;
}
return true;
}
//in the while loop, put this
<?php
$get_active_str = bp_get_member_last_active();
if ($keep_checking_online) {
$is_online = check_user_online_str($get_active_str);
if ($is_online) echo “Online Now!”;
else {
echo $get_active_str;
$keep_checking_online = false;
}
}
else echo $get_active_str;
?>
`
The $keep_checking_online var is used so that the loop stops checking after it finds somebody not online now. This is possible because for bp_has_members( bp_ajax_querystring( ‘members’ ) ) returned members are ordered by last_active.
But we use an online span of 59 minutes – while BP defaults to using 5 minutes.
So you would need to adjust the function check_user_online_str().
If it passes the $needles check, then parse the string to check for ‘minutes’ and ‘seconds’.
If you find ‘minutes’, then get the number after ‘active’ and decide if you want to return true or false.