Advanced search for users

Hey guys,

I would like to have a functionality which woudl enable me to search for other users based on certain profile fields such as "Univeristy Degree", "Gender", "Interests" for a univeristy social media site. I have been looking around and haven't been able to find anything. I've found out that it existed in previous versions of profile manager, but is no longer supported. 

Can someone point me in the right direction please? Im not a very experienced coder, but when push comes to shove, I can manage with non-complex mysql/php/html scripts. 

Thanks guys, Appreciate it

  • Check out this fix for adding profile fields to searches:

    I'm not a programmer, but I was able to make this change to the search plugin pretty easily and it works great on Elgg 1.8.6!

  • You can also make this edit to start.php in the search plugin to allow for partial match returns:

    $where = "(MATCH ($fields_str) AGAINST ('$query*' $options))";

    The difference is the * added after $query. In my plugin it is line 445, but it looks like it is line 447 in the latest release. I can't find the post that suggested this edit but it somewhere here in the forum.

    One thing to mention here is that allowing partial matches is going to generate a lot more matches and may slow down your searches on large sites.

  • good tips ;-P

    database accesses will generally not quite slow down site ~ it's usually the server's responses (@performance) that causes issues.

  • Ed and Dhrup, thanks for your advice! Ed, can did you use profile manager to create additional searchable fields?


  • Yep. However, I haven't had much time to dig into the specifics yet. For example, I haven't yet figured out why some matches return just a user name and others return user names with the matching text.

  • Hi Ed, I've tried implementing your suggestion of adding * to the search and I'm not sure if i'm 100% understanding your idea.

    So lets say an existing search of "Commerce" would return a list of results.

    But with partial match returns, when i search for "Commerce Engineering", results should include everyone who does Commerce and/or Engineering, right? 

    Unfortunately it still seems to return a null result when i search for an existing content + non-existant key words. If the above is how partial match is meant to work, it would be quite strange as i've already added the * to line 447!


  • Sorry, I don't know the mechanics behind these modifications. I just passed along some tips that I found. Hopefully, someone who knows will chime in.

  • I am not sure why you aren't able to search on profile fields. I think this support was added in 1.8.12.

    What issues are you facing? I am able to search on profile fields, using 1.8.12 and 7.4.1 and I don't see anything in 7.5.1 stopping you from searching it. Elgg's design is not optimized for searching, I believe this will need to be addressed pretty soon since search is a very important feature in any social platform.


  • FYI. I think that the fix I posted above is what was implemented in 1.8.12 and is backwards compatible with those of us using older 1.8 versions of Elgg (I know it's compatible with 1.8.6).

    Check out this fix for adding profile fields to searches:

    Sorry, I still don't have an answer for why it returns a null result when searching for existing content + non-existant key words. Perhaps it is because the * only returns strings that include the entire search phrase as part of a longer text string? In other words, you would need to conduct a separate search for each of the Commerce AND Engineering results.

  • Hi Ed.

    You say these changes were implemented in 1.8.12, but I see no advanced search.

    Can you speficy exactly what changes you made?



Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking