MyBB Community Forums

Full Version: Search Memberlist by Custom Field
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like to change the search bar at the bottom of the memberlist from website to a custom profile field (fid4). Changing the template files to reflect that isn't an issue, but I assume something has to be done to the memberlist.php file to make this possible?

If anyone knows the exact changes that would be required to the files, I'd appreciate it. Thanks!
Kylin - I found this old thread

http://community.mybb.com/thread-66854.html

Might work.
Thanks for the response! I actually had already found that thread though and used it Big Grin

The problem is that it pertains to the advanced search only and not the basic one at the bottom of the memberlist page. Of course, I've already made the changes to the advanced search and everything works fine there. But I can't figure out how to change the default "website" search at the bottom of the memberlist to a custom one. I went into the template and changed the value for that field from value="{$search_website}" to value="{$search_fid4}". But it's still not searching for that field. It still searches by website.
It has to be outputting in memberlist php somehow. Possibly this bit?

// Website contains
	$search_website = htmlspecialchars_uni($mybb->input['website']);
	if(trim($mybb->input['website']))
	{
		$search_query .= " AND u.website LIKE '%".$db->escape_string_like($mybb->input['website'])."%'";
		$search_url .= "&website=".urlencode($mybb->input['website']);
	}
I got it working finally but thanks for trying to help! It was really a silly oversight with the template file (I only modified the value field and not the rest of the fields). For everyone else's reference though, I'll just post this here just in case anyone else wants to achieve this and doesn't know how.

Basically, just do the edits in the aforementioned linked post ( http://community.mybb.com/thread-66854.html ). Those edits will add the custom fields to the advanced search page. If you wish to also add one of the custom fields to the bottom of your memberlist page, you'll need to make these next edits as well. In this example, I replaced the website search with a custom field (fid4). You may need to change this based on your needs depending on what custom field you're using. It could be fid1, fid2, etc.

In your templates, you go to "Member List Templates" --> "Memberlist."

Find:
<td class="tcat"><strong><label for="website">{$lang->website}</label></strong></td>

Replace with (changing fid4 to whatever number your custom field is--you'll find this number in your admin panel --> Configuration --> Custom Profile Fields. Look at the ID column for the proper number of the field you want):
<td class="tcat"><strong><label for="fid4">{$lang->fid4}</label></strong></td>

Just below that, find:
<td class="trow1" width="33%" style="vertical-align: top;">
		{$lang->contains}<br />
		<input type="text" class="textbox" name="website" id="website" style="width: 99%; margin-top: 4px;" value="{$search_website}" />

Replace with: (again, change fid4 to whatever you need)
<td class="trow1" width="33%" style="vertical-align: top;">
		{$lang->contains}<br />
		<input type="text" class="textbox" name="fid4" id="fid4" style="width: 99%; margin-top: 4px;" value="{$search_fid4}" />

That's it. Hope someone out there finds that useful Smile

Side note: Remember that when you update MyBB to the next version, your memberlist.php file may be overwritten. As such, you'll likely have to do the edits in the above link all over again.
Excellent - thank you for the share.

If you are doing a lot of edits of core files maybe you could use the patches plugin? That way you make a patch and when you upgrade you just reapply the patches after upgrade.
Cool, thanks! Just to note that this is possible via a plugin using cotrol_object if somebody want to give it a try.