bp_profile_repeaters_search_change_filter( object $f )

If the field is a main/template field for a repeater set, search should have a like ‘%s keyword %s’ query.

Description

Parameters

$f

(object) (Required) Passed by reference

Source

File: bp-xprofile/bp-xprofile-repeaters.php

function bp_profile_repeaters_search_change_filter ( $f ) {
    $field_id = (int) $f->id;
    
    global $wpdb;
    $bp = buddypress();
    
    $field_group_id = $wpdb->get_var( "SELECT group_id FROM {$bp->profile->table_name_fields} WHERE id = {$field_id} AND type != 'option' " );
    $is_repeater_enabled = 'on' == bp_xprofile_get_meta( $field_group_id, 'group', 'is_repeater_enabled' ) ? true : false;
    
    if ( !$is_repeater_enabled ) {
        return $f;
    }
    
    $cloned_from = bp_xprofile_get_meta( $field_id, 'field', '_cloned_from', true );
    if ( !empty( $cloned_from ) ) {
        //This is a clone field. We needn't do anything
        return $f;
    }
    
    //this is a template field
    $f->format = 'text';
    $f->filter = 'contains';
    return $f;
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.