Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i am trying to add a profile based search option into my existing plugin. my plugin already search members by distance within a certain radius and i want to add the option to filter results by profile fields.

what i am trying to do is getting the user id that has the matching values entered in the search form. i am trying something like:

SELECT user_id FROM {$bp->profile->table_name_data} 
WHERE (field_id1 = "field1" AND value1 = "value1")
AND (field_id2 = "field2" AND value2 = "value2")
AND (field_id3 = "field3" AND value3 = "valu3")
........

but this doesn't work. it will work with the WHERE clause only but not when i am adding the ANDs. i assume this is have something to do with joins maybe?

any help would be much appreciated.

share|improve this question

closed as off-topic by ialocin, kaiser Aug 4 at 14:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 1 down vote accepted

Off the top of my head... I can think of a plugin that does this:

http://buddypress.org/community/groups/bp-profile-search/

Perhaps this will provide you with a good starting point for what you're trying to get done.

share|improve this answer
    
Thank you FlashingCursor. I actually already dug in the "profile-search" plugin. i should have mentioned that. I can use the method that plugin uses but i thought i could maybe find a better way. That plugin runs SQL SELECT query against each field within the fields loop and then get the users that exist in all of them. i thought that maybe one Query would run better performance-wise. i might be wrong and if there was a better way i guess it would be already there in that plugin. However, if anyone can provide another way that would be great. Otherwise i guess i could go with the method above. –  Eyal Aug 4 '12 at 21:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.