January 26, 2016 at 18:23
#100618
Moderator
Here is the code which will help you manipulate the field search queries, you need to add it into the functions.php file of your theme
COPY CODE
function kleo_bp_field_query_custom($sql, $field_id, $field_value){
if( $field_id == '1'){ // I am a - field id
$extra_sql = false;
if( $field_value == 'Mężczyzna'){
$extra_sql = 'Mężczyzny';
}
if( $field_value == 'Kobietą'){
$extra_sql = 'Kobiety';
}
if( $extra_sql ){
$extra_sql = " OR value LIKE '%".esc_sql($extra_sql)."%'";
}
$sql = str_replace("value LIKE '%".esc_sql($field_value)."%'", "value LIKE '%".esc_sql($field_value)."%'" . $extra_sql , $sql);
}
if( $field_id == '6'){ // Looking for - field id
$extra_sql = false;
if( $field_value == 'Mężczyzny'){
$extra_sql = 'Mężczyzną';
}
if( $field_value == 'Kobiety'){
$extra_sql = 'Kobietą';
}
if( $extra_sql ){
$extra_sql = " OR value LIKE '%".esc_sql($extra_sql)."%'";
}
$sql = str_replace("value LIKE '%".esc_sql($field_value)."%'", "value LIKE '%".esc_sql($field_value)."%'" . $extra_sql , $sql);
}
return $sql;
}
add_filter ('kleo_bp_field_query', 'kleo_bp_field_query_custom', 100, 3);
Also, in order for this code to work I had to make a small change to a core file which I have attached below and you’ll have to update it over ftp in the main theme: “wp-content/themes/sweetdate/custom_buddypress/kleo-bp-search.php”, and we’ll include this modification in updates as well.
Let me know how it went.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution