Multiple location fields

BP Profile Search › Multiple location fields

  • Author
    Post
  • #10427 Reply
    Michael Spencer
    Guest

    Andrea,
    Is it possible to set up say 3 location fields in a user record, then have one location search that looks in each of these fields. Basically I want to set up a member directory and some members want to be able to list more than one location they work from.

    #10430 Reply
    andrea
    Plugin Author

    Hi Michael,

    Let’s say you have 3 location fields, with IDs 10, 11, and 12.

    You can add to your search form the first field only (field 10), 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' && $f->filter == 'distance')
    		$sql['where'][1] = 'field_id IN (10,11,12)';
    	return $sql;
    }

    This way when you search field 10, you’ll be searching fields 11 and 12 as well.

Reply to: Multiple location fields
My Information