Support » Plugin: BP Profile Search » Filter more than one Profile Fields with one Search (Hobby Filter)

  • Resolved nilsfischerinfo


    Hello and thanks for the greate plugin.

    I added a Search Form to my Buddypress Members Directory with a couple of fields like Keyword, Role, Country and Hobby. It works well.

    The User can enter 4 Hobbies in his Profile in 4 separate Fields via Dropdown for each Field (10 Possibilities are predefined). E.g. Hobby 1 is Sport, Hobby 2 is Party, Hobby 3 Reading and Hobby 4 is Musik. Now I want to implement a custom Search Field for Hobbies.

    There should be Search Field as a Dropdown (Same 10 Possibilities) in the Member Directory. Like if I search for Sport all 4 Hobby Fields should be checked for Sport. Somebody has Sport in Hobby Field 1 and another in Hobby Field 4 but both are interested in Sport and should be displayed as result.

    Thanks for you help and your great work.

    All the best.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrea Tarantini


    Hi nilsfischerinfo,

    Let’s say the field IDs of your four “Hobby” fields are 10, 12, 13, 18 (replace with you real field IDs in what follows).

    Now build a search form as usual for the first field (ID 10) and make sure it works correctly for that single field.

    Then 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->code == 'field_10')
    		$sql['where']['field_id'] = 'field_id IN (10,12,13,18)';
    	return $sql;

    Remember to replace 10, 12, 13, 18 with the real field IDs of your “Hobby” fields.

    Thread Starter nilsfischerinfo


    Thanks your for the very fast support. Works perfect.

    Plugin Author Andrea Tarantini


    You are welcome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.