Skip to:
Content
Pages
Categories
Search
Top
Bottom

Function works here, but not there


  • metalhead
    Participant

    @aaronthomas1979

    In the support forums, I found this great function to display whether a user is “online,” or “offline,” in the member-header. It works great in the member-header file, but to my surprise, it doesn’t work in members-loop.

    Here is the function:

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

    When I try to call this function in my members-loop, the members list always says “not online,” even when a user IS online.

    Is there a simple solution to this?

    PS) It seems likely that this question has already been answered in the past, but I can not seem to find anything about it in the forums. I’m probably using the wrong keywords, but I really did try!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar