Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/01/2009 11:42:29 PM (17 years ago)
Author:
apeatling
Message:

Updating autocomplete so that it does not require loading of the WP environment separately.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/bp-messages-ajax.php

    r1412 r1497  
    2626}
    2727add_action( 'wp_ajax_messages_send_reply', 'messages_ajax_send_reply' );
     28
     29function messages_ajax_autocomplete_results() {
     30    global $bp;
     31
     32    // Get the friend ids based on the search terms
     33    $friends = apply_filters( 'bp_friends_autocomplete_list', friends_search_friends( $_GET['q'], $bp->loggedin_user->id, $_GET['limit'], 1 ), $_GET['q'], $_GET['limit'] );
     34   
     35    if ( $friends['friends'] ) {
     36        foreach ( $friends['friends'] as $user_id ) {
     37            $ud = get_userdata($user_id);
     38            $username = $ud->user_login;
     39            echo bp_core_get_avatar( $user_id, 1, 15, 15 ) . ' ' . bp_fetch_user_fullname( $user_id, false ) . ' (' . $username . ')
     40            ';
     41        }       
     42    }
     43}
     44add_action( 'wp_ajax_messages_autocomplete_results', 'messages_ajax_autocomplete_results' );
    2845
    2946function messages_ajax_markunread() {
Note: See TracChangeset for help on using the changeset viewer.