Skip to:
Content

BuddyPress.org

Changeset 4891


Ignore:
Timestamp:
07/28/2011 11:04:38 PM (13 years ago)
Author:
boonebgorges
Message:

Joins xprofile data field separately for members directory search and for members directory alphabetical sort, to ensure proper search domain. Fixes #3403. Props lpryor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-classes.php

    r4829 r4891  
    223223        $sql['from'] = "FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON um.user_id = u.ID";
    224224
    225         if ( $search_terms && bp_is_active( 'xprofile' ) || 'alphabetical' == $type )
    226             $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
     225        // We search against xprofile fields, so we must join the table
     226        if ( $search_terms && bp_is_active( 'xprofile' ) )
     227            $sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
     228
     229        // Alphabetical sorting is done by the xprofile Full Name field
     230        if ( 'alphabetical' == $type )
     231            $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
    227232
    228233        if ( $meta_key )
     
    271276        if ( $search_terms && bp_is_active( 'xprofile' ) ) {
    272277            $search_terms             = like_escape( $wpdb->escape( $search_terms ) );
    273             $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
     278            $sql['where_searchterms'] = "AND spd.value LIKE '%%$search_terms%%'";
    274279        }
    275280
Note: See TracChangeset for help on using the changeset viewer.