Skip to:
Content
Pages
Categories
Search
Top
Bottom

displayed user is logged in


  • Jonas Lundman
    Participant

    @intervik

    Hi, searched for weeks for this, now start posting here… Propably simple solution.
    I need a true/ false statement if a user_id (not me) IS logged in. In worst case, IS online (active less than those % MINUTES)
    like bp_is_logged_in(id) or a default wp call or something.

    / thankful any directions here

Viewing 7 replies - 1 through 7 (of 7 total)

  • Jonas Lundman
    Participant

    @intervik

    Note. type=online will not work when other types needed, and multiple loops avoiding c we have 18 000 members…


    modemlooper
    Moderator

    @modemlooper

    is_user_logged_in()


    Jonas Lundman
    Participant

    @intervik

    Thanks, but it seems to apply me as logged in, not the profile im visit. “I need a true/ false statement if a user_id (not me)”


    modemlooper
    Moderator

    @modemlooper

    EDIT:

    `
    function bp_is_displayed_user_online(){
    $member_id = bp_displayed_user_id();
    if (bp_has_members(‘user_id=0&type=online’)) :
    while (bp_members()) : bp_the_member();
    if($member_id == bp_get_member_user_id()) return true;
    endwhile;
    endif;
    }

    function bp_is_online(){
    if ( bp_is_displayed_user_online() )
    echo ‘online!’;

    }
    add_action(‘bp_before_member_header_meta’, ‘bp_is_online’);
    `


    nitestop
    Participant

    @nitestop

    isnt there a plugin for this already on here


    Jonas Lundman
    Participant

    @intervik

    Thanks. As my note above, We have 18 000 members, and loop them for a simpe boolean seems heavy (if id == 17999…). Isnt there a smart php session solution, if the core doesnt provide a ONLINE ARRAY ?


    chroniko
    Participant

    @chroniko

    better solution to check online users:

    `
    function bp_is_user_online($member_id=0){
    if(!$member_id)
    $member_id = bp_displayed_user_id();
    $now = time();
    $last_activity = bp_get_user_meta($member_id, ‘last_activity’, true);
    $last_activity = strtotime($last_activity);
    if( ($last_activity + 300) >= $now )
    return true;
    }
    `
    300 (in seconds) is default buddypress interval to check online users.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘displayed user is logged in’ is closed to new replies.
Skip to toolbar