Bit of a drag that we have to loop thru all members, but this works and I couldn’t figure out a better way
http://code.hyperspatial.com/all-code/buddypress-code/is-user-online/
I use a version of this on profile pages (member-header.php) – it’s faster than the code in the url above because it only checks one user.
`
function check_is_user_online($user_id){
if ( bp_has_members( ‘type=online&include=’.$user_id) ) return true;
else return false;
}
$this_id = $bp->displayed_user->id;
$is_online = check_is_user_online($this_id);
if ($is_online) echo “NOW ONLINE”;
else bp_last_activity( $this_id );
`
why thank you but I get:
`Fatal error: Call to undefined function bp_has_members()`
when I put into bp-custom
You’d have to use action or filter hooks if you put it in bp-custom
Try putting it in a template file, like member-header
When I just put it in the file, nothing comes up but the user’s `”active * minutes ago”` text.
So, when I call the function, I get:
`Warning: Missing argument 1 for check_is_user_online(), called in ***/members/single/member-header.php on line 68 and defined in ***/members/single/member-header.php on line 71`
Any ideas?
Add this before the function
global $bp;
I get the error that function_im_awesome posted above, even with global $bp; added.
Shane when I try to put your code in I get:
`Warning: Missing argument 1 for check_is_user_online()`
please replace `$this_id = $bp->displayed_user->id;`
with this `$this_id = bp_displayed_user_id();`
it worked but I still got a big fat error above it:
`Warning: Missing argument 1 for check_is_user_online()`
could you post the code your using? This warning isn’t happening when i tested it.
Yay! it works for me.
Now how can I put it in the topic?
I tried putting it in the topic template file but I keep getting a
`Fatal Error: Cannot Redeclare`
but it’s saying I declared it twice in the same file, which I didn’t!
but then when I just put:
“ in the topic, I get;
`Fatal Error: Called to Undefined Function check_is_user_online()`
ARRRG!
How can I put it on bp-custom??? so it wont give me “call to undefined” error????
please?? how do you put it in the topic?
let me look into this, it might take me a while seeing as I do not have a bp site of my own
I can test it all for you.
Anything you want, if I havn’t done it already, I have had like 3 hours of trial and error already.
I was saying I need to locate the topics folder, but not have luck making the forums work
Any update on this timothy?
Did anyone fixed this?
With the latest bp it always shows online, even if the user is offline.