Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/25/2009 10:15:42 PM (16 years ago)
Author:
apeatling
Message:

Moving autocomplete results function to deprecated file as it is now in the theme and was causing duplicate results.

File:
1 edited

Legend:

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

    r1905 r1957  
    162162add_action( 'wp_ajax_messages_close_notice', 'messages_ajax_close_notice' );
    163163
     164function messages_ajax_autocomplete_results() {
     165    global $bp;
     166
     167    /* If we are using a BuddyPress 1.1+ theme ignore this. */
     168    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     169        return false;
     170           
     171    $friends = false;
     172
     173    // Get the friend ids based on the search terms
     174    if ( function_exists( 'friends_search_friends' ) )
     175        $friends = friends_search_friends( $_GET['q'], $bp->loggedin_user->id, $_GET['limit'], 1 );
     176
     177    $friends = apply_filters( 'bp_friends_autocomplete_list', $friends, $_GET['q'], $_GET['limit'] );
     178
     179    if ( $friends['friends'] ) {
     180        foreach ( $friends['friends'] as $user_id ) {
     181            $ud = get_userdata($user_id);
     182            $username = $ud->user_login;
     183            echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) )  . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ')
     184            ';
     185        }       
     186    }
     187}
     188add_action( 'wp_ajax_messages_autocomplete_results', 'messages_ajax_autocomplete_results' );
     189
    164190/* Deprecated -- use messages_new_message() */
    165191function messages_send_message( $recipients, $subject, $content, $thread_id, $from_ajax = false, $from_template = false, $is_reply = false ) {
Note: See TracChangeset for help on using the changeset viewer.