if ( !empty( $users['users'] ) ) {
// Build an array with the correct format
$user_ids = array();
foreach( $users['users'] as $user ) {
if ( $user->id != $bp->loggedin_user->id )
$user_ids[] = $user->id;
}
$user_ids = apply_filters( 'bp_core_autocomplete_ids', $user_ids, $_GET['q'], $limit );
}
} else {
if ( bp_is_active( 'friends' ) ) {
$users = friends_search_friends( $_GET['q'], $bp->loggedin_user->id, $limit, 1 );
// Keeping the bp_friends_autocomplete_list filter for backward compatibility
$users = apply_filters( 'bp_friends_autocomplete_list', $users, $_GET['q'], $limit );
if ( !empty( $users['friends'] ) )
$user_ids = apply_filters( 'bp_friends_autocomplete_ids', $users['friends'], $_GET['q'], $limit );