Searching custom user profile fields
stretchwickster - April 26, 2006 - 20:20
Drupal 4.6.5
Dear All,
I've created a fair number of custom user profile fields using the profile module, comprising mainly drop-down boxes and checkboxes. What is the best way to implement a user search facility, whereby the user navigates to a "search members" page, and is presented with controls for interrogating a combination of the custom fields? For example, a search could be made for all members who live in the United Kingdom, speak French and enjoy walking and those members who match the search criteria would then listed.
Any suggestions would be most welcome as I don't really know where to start.

profile
assume you mean you used profile module not flexinode?
-----
Drupal ecommerce, at http://www.drupalecommerce.com is a new site written using language that Drupal beginners and intermediate users can understand. Quick links to "Modules" and "Module Groupings."
Yes I used the profile
Yes I used the profile module.
User profile vs flexinode
Whoa! No default profile search? My client requires it. With all the descriptors attached to the profile node, I assumed they would be searchable.
I was just about to create the custom user profiles. If I use a custom flexinode, will they be searchable without installing an extra module?
TIA,
D. Lynn
User Search Module
I'm working on a module that enables profile searches:
http://drupal.org/node/58788
It's still at a Beta stage, the features are there, and searching works - now I'm sorting out the way results are displayed.
Cortext Communications
Drupal Themes & Modules
That sounds good. I'll have
That sounds good. I'll have to try that out.
4.7
nice. will you be doing 4.7 also?
-----
Drupal ecommerce, at http://www.drupalecommerce.com is a new site written using language that Drupal beginners and intermediate users can understand. Quick links to "Modules" and "Module Groupings."
Yes
Yes, will evetually get ported to 4.7, but for the moment I need this for some 4.6 sites.
Cortext Communications
Drupal Themes & Modules
thx
great. thanks.
-----
Drupal ecommerce, at http://www.drupalecommerce.com is a new site written using language that Drupal beginners and intermediate users can understand. Quick links to "Modules" and "Module Groupings."
Testing profile searches
Robert, it looks like your user_search module is what I'm looking for. In order to run some test searches, is there a quick way to create dummy users because you need a separate email account for each one?
developer module
I think the developer module has a function to create test users.
Cortext Communications
Drupal Themes & Modules
Development of results display
Robert, I would be most grateful if you could keep me posted regarding any developments to the display of results.
Update
Latest version allows control of what search fields and results fields are shown, now working on ordering of fields, on both search and results. After that need to allow for result fields to be concatenated and given a new label - e.g. Name: %first_name %last_name
Cortext Communications
Drupal Themes & Modules
configure search form - not displaying all categories
Robert,
On the "configure search form" (url: admin/settings/user_search), there's a group box entitled "Category Order". Inside this group box is a list of profile categories. Unfortunately, only 5 of my 8 categories are displayed.
I've been trying to debug the code in theme_user_search_configure_form but I can't figure it out. $category_count equals 8, which is correct but further down values are stripped out of $sort_order (populated from $form_values) to populate the category list and $sort_order only comprises 5 categories??
Consequently, when I go to do an Advanced User Search, I don't have all the group boxes displayed.
Layout of the custom profile fields on the User Search page
Drupal 4.6.5 with a theme derived from bluemarine (xtemplate)
Robert,
I have added a large number of custom user profile fields (about 60) using the profile module and would like to improve the layout of the User Search page. Currently, each fields is displayed on a new line, how would I go about making more efficient use of the screen real estate (e.g. perhaps I could double up the fields so that two appear per line)? What section of which file do I need to edit to effect this change?
Your advice would be much appreciated!
theme_user_search_advanced()
In the user_search.module look for the line:
function theme_user_search_advanced($profile_fields, $form_values) {You can style all of the content in that function however you like:
http://drupal.org/node/11811
Cortext Communications
Drupal Themes & Modules
Thanks for that Robert -
Thanks for that Robert - I'll try editing it later. I'm guessing I need do a series of checks e.g. if field is "Language Spoken" then place that next to "Gender" - is that the correct approach to editing the theme_user_search_advanced function?
I know this isn't your module, but where would I need to look for editing the Registration page fields (see the full question at http://drupal.org/node/67568)?
Now Available
User Search module is now available for Drupal 4.6, and being worked on for 4.7....
http://drupal.org/node/58788
Cortext Communications
Drupal Themes & Modules
So does this latest version
So does this latest version include the items you mentioned in your post (11 May 2006) in this topic?
Yes
Yes, plus a few other niceties.
Cortext Communications
Drupal Themes & Modules
thank you
Robert, thank you very much. I'm looking forward to using it. Any idea when 4.7 will be ready? (1 week, 1 month, or beyond?) Do you need 4.7 for one of your sites, or might it get pushed quite far down the list of priorities for you? It sounds like a great module.
Drupal ecommerce, at http://www.drupalecommerce.com
http://www.drupalecommerce.com/troubleshooting
http://www.drupalecommerce.com/modulesexplained
http://www.drupalecommerce.com/47vs46
http://www.drupalecommerce.com/howto
Soonish
There's a few people working on it, so hopefully soonish.
I need it towards the end of next month for my sites, so if it's not done in the next few weeks I'll update it myself.
Cortext Communications
Drupal Themes & Modules
SQL Error after clicking Search button
Robert,
I just installed your latest User Search module from the link you specified and I get the following 2 errors after clicking the Search button:
"user error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1..."
and
"user error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 5' at line 1..."
I have not reproduced the SQL Query because it gets truncated, as I have 60 custom profile fields.
The page loads underneath these messages and "No users where found" is reported under the "Basic Search" tab. Incidentally, it should be "No users were found".
Please advise.
Bugs
Thanks for the feedback, could you create an issue for the module:
http://drupal.org/node/add/project_issue/user_search/bug
I don't have time to work on this at the moment, but when I do I'll be using the bug tracker to look at issues.
Cortext Communications
Drupal Themes & Modules
Submit issue to bug tracker
Ok, will do when I get a chance.
performance of user_search module
Has anyone analysed the user_search modules performance implications. From what I can see, the query used to search users does a LEFT JOIN for each field on the profile. So, if I have 50 fields on the user profile, the query does 50 LEFT JOINS with the users table. I am concerned about the performance of this query as number of users, profile fields increase.
Am I better off writing a custom module if my profile fields are fairly constant ?
vs flexinode
that's a good question. Would flexinode would be equivalent in terms of LEFT JOIN, or is one or the other better in terms of this performance issue?
Drupal ecommerce, at http://www.drupalecommerce.com
http://www.drupalecommerce.com/troubleshooting
http://www.drupalecommerce.com/modulesexplained
http://www.drupalecommerce.com/47vs46
http://www.drupalecommerce.com/howto
Metrics
Would be great if you could try it out and give us some feedback - number of field, number of users, speed of search.
Go to admin/logs/pages to see 'Average page generation time', or even better install the dev.module and test how long the sql query took.
Cortext Communications
Drupal Themes & Modules
Just for your information...
Just for your information, I had been using the cvs version (which I assume is for 4.7.0) of user_search instead of the 4.6.0 version. Now everything works fine - no bugs!
Profile filtering
I've added this http://drupal.org/node/67084 module that allows profile filtering allowing you to narrow down the listing of users based on profile fields.
announce
Thank you. That's great, and it sounds like a useful module. Perhaps you can post a new forum thread letting people know about this module. It's the first I've heard of it but it does something that's often requested.
Drupal ecommerce, at http://www.drupalecommerce.com
http://www.drupalecommerce.com/troubleshooting
http://www.drupalecommerce.com/modulesexplained
http://www.drupalecommerce.com/47vs46
http://www.drupalecommerce.com/howto
Any chance on 4.5?
This module is exactly what I'm looking for. Any chance you could modify this module for 4.5? I am reluctant to upgrade my site to 4.6 due to a large number of modifications I've made to 4.5.
Craig
Nope
No chance of a downgrade to 4.5
Try it, it might work anyway.
Cortext Communications
Drupal Themes & Modules
Thanks for the suggestion.
Thanks for the suggestion. The 4.6 module didn't work in 4.5. After enabling it, I tried to access the settings page for this module and I was re-directed to an empty (blank) page. Is there anything quick and dirty I could do to hack this module to make it compatible? I ask this because I have no idea on how modules are written or structured.
4.6 => 4.5
Go through this page and do everything in reverse:
http://drupal.org/node/12347
But instead I would highly recomend getting your site updated to 4.6, apart from the extra features, there are also security issues to consider.
Cortext Communications
Drupal Themes & Modules
Limiting search page to selected fields, results display
This module is very useful, thanks! And the results page looks great, with user picture and link to full profile, everything one would want. :^)
Only one problem, I configured the search form to display only 10 of the 22 user profile fields (and saved the config of course), but all 22 fields are still being listed. Have any idea where I should start looking for the problem?
Version #: 4.6.5.
Thanks,
D. Lynn
Issue
I haven't come across that problem.
Could you create an issue for it and add as much info as you can:
http://drupal.org/node/58788
Cortext Communications
Drupal Themes & Modules
Hi Robert, have you looked
Hi Robert, have you looked at the issue queue lately? I posted something a couple weeks ago. There are a few related entries there; Stretchwickster and I have done some troubleshooting. We're both having the same problem. Neither of us is ready to upgrade to 4.7 yet, so we hope you will give the 4.6 version a second look.
Appreciatively,
D. Lynn
Running on a 4.7.2?
Hi,
First at all: thanks for the module. It looks really promissing... and it's exactly what I was looking for.
Second... does any body know if is planed to be ported to 4.7.2 or if is ported yet? I made some search in drupal.org and I didn't found much information about this issue.
Thanks a lot in advance for your help,
m.
silly me...
I read this same thread in detail and I found you already answered this question in former posts...
Do you need help with the porting? I'm really interested in make it run so I planned to do something similar (with my basic programming skills :-P).
Let me know how I could help with testing and/or programing over 4.7.2.
Cheers,
m.
4.7 Update
Yep, anyone else interested in helping with the 4.7 update go to this thread:
http://drupal.org/node/66332
Cortext Communications
Drupal Themes & Modules
Various Modules being worked on...
Just want to save some work for people in the future. There are a few modules being worked on to create a way to search through user profiles. There are also a few hacks, but I am leaving them out of the results. You can find them if you search the forums.
-) Advanced User - http://drupal.org/node/70339
-) Profile Plus - http://drupal.org/node/55469
-) Views Profile - http://drupal.org/node/73245
-) User Search - http://drupal.org/node/66332
Hopefully some or all of the people working on these will come up with a great solution for us!
To allow searches by all
To allow searches by all users, I made few changes to the advanced user module
Can u guys try it out and let me know?
http://drupal.org/node/70339