Skip to:
Content
Pages
Categories
Search
Top
Bottom

Member Online in Profile


  • johnkim1968
    Participant

    @johnkim1968

    Hi,

    I want to show whether the member is online in the profile page. How can I do that? I found the code from Shanebp for the members-loop but I’m not sure how to apply it to the profile page or whether it would even work. Can someone point me in the right direction?

    function is_user_online( $user_id, $time=5 ) {
    
       $last_activity = bp_get_user_last_activity( $user_id );
    
       $curr_time = time(); 
    
       $diff = $curr_time - strtotime( $last_activity );
    
       $time *= 60;  // must be in seconds
    
       if( $diff < $time )
          return true;
       else 
          return false;
    }
Viewing 3 replies - 1 through 3 (of 3 total)

  • shanebp
    Moderator

    @shanebp

    Try this in your theme/functions.php or bp-custom.php

    function is_user_online() {
    
       $last_activity = bp_get_user_last_activity( bp_displayed_user_id() );
    
       $curr_time = time(); 
    
       $diff = $curr_time - strtotime( $last_activity );
    
       $time = 5 * 60;  // must be in seconds
    
       if( $diff < $time )
          echo '<br/>online';
       else 
          echo '<br/>not online';
    }
    add_action('bp_before_member_header_meta', 'is_user_online');

    johnkim1968
    Participant

    @johnkim1968

    Thanks Shanebp, got it working. I have some custom work I need to have done for my site, are you available? How do I contact you?


    shanebp
    Moderator

    @shanebp

    Check my profile.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Member Online in Profile’ is closed to new replies.
Skip to toolbar