Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How to display if User is Online or Not in Forum Topic and Profile

  • @vegasparty607

    Participant

    Is there any native function?

    How do you do it? I want like some text to be there “Online” if he is online.

Viewing 25 replies - 1 through 25 (of 26 total)
  • @vegasparty607

    Participant

    Nobody?

    @shanebp

    Moderator

    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/

    @shanebp

    Moderator

    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 );
    `

    @vegasparty607

    Participant

    why thank you but I get:

    `Fatal error: Call to undefined function bp_has_members()`

    when I put into bp-custom

    @shanebp

    Moderator

    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

    @vegasparty607

    Participant

    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?

    @shanebp

    Moderator

    Add this before the function
    global $bp;

    @cheese-1

    Member

    I get the error that function_im_awesome posted above, even with global $bp; added.

    @cheese-1

    Member

    Shane?????

    @maple-syrup

    Member

    Shane when I try to put your code in I get:

    `Warning: Missing argument 1 for check_is_user_online()`

    @timothyjunior

    Participant

    please replace `$this_id = $bp->displayed_user->id;`
    with this `$this_id = bp_displayed_user_id();`

    @maple-syrup

    Member

    it worked but I still got a big fat error above it:

    `Warning: Missing argument 1 for check_is_user_online()`

    @timothyjunior

    Participant

    could you post the code your using? This warning isn’t happening when i tested it.

    @vegasparty607

    Participant

    Yay! it works for me. :)

    Now how can I put it in the topic?

    @vegasparty607

    Participant

    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!

    @vegasparty607

    Participant

    why is it doing that!???

    Sorry i’m so close!!

    @vegasparty607

    Participant

    Timothy?

    Shane?

    @vegasparty607

    Participant

    How can I put it on bp-custom??? so it wont give me “call to undefined” error????

    @vegasparty607

    Participant

    please?? how do you put it in the topic?

    @timothyjunior

    Participant

    let me look into this, it might take me a while seeing as I do not have a bp site of my own

    @vegasparty607

    Participant

    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.

    @timothyjunior

    Participant

    I was saying I need to locate the topics folder, but not have luck making the forums work

    @vegasparty607

    Participant

    whaa???

    im confused.

    @vegasparty607

    Participant

    Any update on this timothy?

    @muhang

    Member

    Did anyone fixed this?
    With the latest bp it always shows online, even if the user is offline.

Viewing 25 replies - 1 through 25 (of 26 total)
  • The topic ‘[Resolved] How to display if User is Online or Not in Forum Topic and Profile’ is closed to new replies.
Skip to toolbar