Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to list friends of a member on main page?


fishbowl81
Participant

@fishbowl81

yes

it is just sql…

line 260 from bp-friends-classes.php Version 813 (has not been adjusted for new $bp changes)

function get_random_online_friends( $user_id, $total_friends = 5 ) {

global $wpdb, $bp;

$sql = $wpdb->prepare( “SELECT u.friend_user_id, u.initiator_user_id FROM {$wpdb->base_prefix}usermeta um LEFT JOIN ” . $bp . ” u ON u.ID = um.user_id WHERE um.meta_key = ‘last_activity’ AND (u.friend_user_id = %d || u.initiator_user_id = %d) && u.is_confirmed = 1 AND DATE_ADD( FROM_UNIXTIME(um.meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY rand() LIMIT %d”, $user_id, $user_id, $total_friends );

$results = $wpdb->get_results($sql);

for ( $i = 0; $i < count($results); $i++ ) {

$fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id;

}

// remove duplicates

if ( count($fids) > 0 )

return array_flip(array_flip($fids));

else

return false;

}

reference: get_online_users, in bp-core-classes

Skip to toolbar