global $bp;
// Include everyone in the autocomplete, or just friends?
if ( $bp->messages->slug == $bp->current_component )
$autocomplete_all = $bp->messages->autocomplete_all;
$friends = false;
$pag_page = 1;
$limit = $_GET['limit'] ? $_GET['limit'] : apply_filters( 'bp_autocomplete_max_results', 10 );
// Get the user ids based on the search terms
if ( !empty( $autocomplete_all ) ) {
$users = BP_Core_User::search_users( $_GET['q'], $limit, $pag_page );
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 )