Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

  • Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    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)
  • Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    Nobody?

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    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/

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

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

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    why thank you but I get:

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

    when I put into bp-custom

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    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

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    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?

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Add this before the function
    global $bp;

    Profile photo of Profile Name
    Profile Name
    Member

    @cheese-1

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

    Profile photo of Profile Name
    Profile Name
    Member

    @cheese-1

    Shane?????

    Profile photo of Maple Syrup
    Maple Syrup
    Member

    @maple-syrup

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

    `Warning: Missing argument 1 for check_is_user_online()`

    Profile photo of Timothy Tarmon Jr
    Timothy Tarmon Jr
    Participant

    @timothyjunior

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

    Profile photo of Maple Syrup
    Maple Syrup
    Member

    @maple-syrup

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

    `Warning: Missing argument 1 for check_is_user_online()`

    Profile photo of Timothy Tarmon Jr
    Timothy Tarmon Jr
    Participant

    @timothyjunior

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

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    Yay! it works for me. :)

    Now how can I put it in the topic?

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    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!

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    why is it doing that!???

    Sorry i’m so close!!

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    Timothy?

    Shane?

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

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

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

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

    Profile photo of Timothy Tarmon Jr
    Timothy Tarmon Jr
    Participant

    @timothyjunior

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

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    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.

    Profile photo of Timothy Tarmon Jr
    Timothy Tarmon Jr
    Participant

    @timothyjunior

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

    Profile photo of function_im_awesome() {
    function_im_awesome() {
    Participant

    @vegasparty607

    whaa???

    im confused.

    Any update on this timothy?

    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