Search multiple fields with one text box

Home Forums BP Profile Search Forum Search multiple fields with one text box

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7830 Reply
    Gar1
    Guest

    First, thank you for the super plugin.

    Is it possible to use one text field to search over multiple xprofile fields?

    Example: We track Last Name and Previous Last Name (maiden name) and we would like the search form to return results if the user’s Last Name OR Previous Last Name is entered in the Last Name field in the search form.

    Are there any hooks that can be used to accomplish this. Of course I would like to extend the plugin without losing the customization with future plugin updates.

    Thank you.

    #7831 Reply
    andrea
    Keymaster

    Hi Gar1,

    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;
    }
    
    #7832 Reply
    Gar1
    Guest

    This code worked very well for my purpose once I updated to the latest version of the plugin (bps-xprofile.php was not in the older version I was using.)

    Thank you andrea for your quick reply.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Search multiple fields with one text box
Your information: