Note. type=online will not work when other types needed, and multiple loops avoiding c we have 18 000 members…
Thanks, but it seems to apply me as logged in, not the profile im visit. “I need a true/ false statement if a user_id (not me)”
EDIT:
`
function bp_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 bp_is_online(){
if ( bp_is_displayed_user_online() )
echo ‘online!’;
}
add_action(‘bp_before_member_header_meta’, ‘bp_is_online’);
`
isnt there a plugin for this already on here
Thanks. As my note above, We have 18 000 members, and loop them for a simpe boolean seems heavy (if id == 17999…). Isnt there a smart php session solution, if the core doesnt provide a ONLINE ARRAY ?
better solution to check online users:
`
function bp_is_user_online($member_id=0){
if(!$member_id)
$member_id = bp_displayed_user_id();
$now = time();
$last_activity = bp_get_user_meta($member_id, ‘last_activity’, true);
$last_activity = strtotime($last_activity);
if( ($last_activity + 300) >= $now )
return true;
}
`
300 (in seconds) is default buddypress interval to check online users.