Hi mtharani,
Sorry for the late reply. You can use the filter ‘bps_field_sql’, see the file bps-xprofile.php, line 139. A possible code snippet is:
add_filter ('bps_field_sql', 'change_query', 10, 2);
function change_query ($sql, $f)
{
if ($f->id == 10) $sql['where']['field_id'] = 'field_id IN (10,12)';
return $sql;
}
I’m having this issue as well. Can you tell us where exactly to put the code? Does it need to replace the other code, etc. I tried adding it stand-alone and it didn’t fix it. Thanks.
Hi @zo1234,
You can add the above code in your bp-custom.php file. Of course you have to replace 10 with the field ID of the field that appears in your search form, and the list 10,12 with the list of the field IDs that are to be searched.
Thanks for response!
Crap, I think I phrased what I said wrong, sorry I don’t know much about PHP. I think I meant how to search across multiple Field Groups, or is the solution similar?
I have this issue:
– I have multiple Field Groups (tabbed)
– The content of Field Groups is duplicate content, only the Field Group name is different.
For example
User Profile
Field Groups
> Info
– Name
– About
> Player Card 1
– Height
– Weight
> Player Card 2
– Height
– Weight
Is there a specific code to make sure searches include “Height” and “Weight” for BOTH Field Groups? Reason is this would save space, etc. instead of including “Player 1” and “Player 2” in search form. Thank you!
Thanks for response!
I think I phrased what I said wrong, sorry I don’t know much about PHP. I think I meant how to search across multiple Field Groups, or is the solution similar?
I have this issue:
– I have multiple Field Groups (tabbed)
– The content of Field Groups is duplicate content, only the Field Group name is different.
For example
User Profile
Field Groups
> Info
– Name
– About
> Player Card 1
– Height
– Weight
> Player Card 2
– Height
– Weight
Is there a specific code to make sure searches will include “Height” and “Weight” for BOTH “Player 1” and “Player 2” Field Groups? So that one search for “Height” spans multiple fields. Reason is this would save space, etc. instead of including “Player 1” and “Player 2” in search form. Thank you!
Hi @zo1234,
Yes, the solution is the one posted above. If, for instance, your field IDs are as follows:
> Player Card 1
– Height (ID 10)
– Weight (ID 11)
> Player Card 2
– Height (ID 12)
– Weight (ID 13)
you have to add this code to your bp-custom.php file:
add_filter ('bps_field_sql', 'change_query', 10, 2);
function change_query ($sql, $f)
{
if ($f->id == 10) $sql['where']['field_id'] = 'field_id IN (10,12)';
if ($f->id == 11) $sql['where']['field_id'] = 'field_id IN (11,13)';
return $sql;
}
In your search form, you’ll specify only the fields with ID 10 and 11, but the search will work for the other fields too, as intended.
This worked, thanks alot appreciate it!