Skip to:
Content
Pages
Categories
Search
Top
Bottom

Perfect match default search – solved

  • Avatar of Devweb
    devweb
    Participant

    @devweb

    Hi all, thought some might find this useful:

    If you require ‘exact match’ searching for the default BP member search – open bp_core_classes.php in bp-core file, on about line 247 enter the following:

    /*$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id ORDER BY pd.value ASC", $search_terms );*/

    $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE pd.field_id=1 AND pd.value = '$search_terms' ORDER BY pd.value ASC", $search_terms );

    /*$paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );*/

    $paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE pd.field_id=1 AND pd.value = '$search_terms' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );

    I have commented the two original lines for reference.

    Hope this is useful!

    Thanks, devweb

Viewing 1 replies (of 1 total)
  • Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    Instead of hacking the core, I would suggest placing any core-modifying code in the bp-custom.php file.

Viewing 1 replies (of 1 total)

The topic ‘Perfect match default search – solved’ is closed to new replies.