Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Filter members loop

@henrywright

Moderator

Brajesh seems to have done most of the heavy lifting for what you want. He uses the bp_ajax_querystring filter, so lets borrow his idea and make our own function to exclude friends from the loop.

function rosyteddy_exclude_users( $querystring = false, $object = false ) {

    // Only do this for the members loop.
    if ( $object != 'members' )
        return $querystring;

    // Get an array of friend IDs for the logged-in user.
    $ids = friends_get_friend_user_ids( get_current_user_id() );

    // Make the array a comma sep list.
    $ids = implode( ',', $ids );

    $args = wp_parse_args( $querystring );

    if ( ! empty( $args['exclude'] ) )
        $args['exclude'] = $args['exclude'] . ',' . $ids;
    else
        $args['exclude'] = $ids;

    $querystring = build_query( $args );

    return $querystring;
}
add_action( 'bp_ajax_querystring', 'rosyteddy_exclude_users', 20, 2 );

Note: I haven’t tested.

Skip to toolbar