Memberlist -- Custom Profile Field Sorting
For vBulletin 3.6.0
Description
By default, vBulletin cannot show just a single custom field on the memberlist, nevermind make it sortable. It's all or nothing.. I wanted to display just the location field and make it sortable, because I use the CountryFlag modification. I searched vbulletin.org to see if this was possible, but all that I could find was unanswered questions similarly asking how to do it. So I took it on myself to get something usable and working.
Instructions
Upload the PLUGIN, and edit it via the Plugin Manager.
Find:
Change urlname to the variable you want to be used in the URL of the memberlist sorting. My example is location.
Find:
PHP:
$sqlsort = 'userfield.fieldX';
Change X to the field number of your custom profile field. My example is 2.
Now you have 2 templates to edit. First, memberlist.
Find:
PHP:
<if condition="$show['homepagecol']"><td class="thead" nowrap="nowrap">$vbphrase[home_page]</td></if>
Above it, add:
PHP:
<td class="thead" nowrap="nowrap"><a href="$sorturl&order=DESC&sort=urlname&pp=$perpage$usergrouplink">Title</a> $sortarrow[urlname]</td>
Use DESC or ASC depending on which default sort order that you wish to use. Change both instances of urlname to the variable that you specified in the plugin earlier (location). Change Title to the title of the field that you wish to be displayed. My example is Location.
Now edit the memberlist_resultsbit template.
Find:
PHP:
<if condition="$show['homepagecol'] AND exec_switch_bg()"><td class="$bgclass"><if condition="$show['homepagelink']"><a href="$userinfo[homepage]" target="_blank"><img src="$stylevar[imgdir_button]/home.gif" alt="home.gif" title="<phrase 1="$userinfo[username]">$vbphrase[visit_xs_homepage]</phrase>" border="0" /></a><else /> </if></td></if>
Above it, add:
PHP:
<if condition="exec_switch_bg()"><td class="$bgclass"><if condition="$userinfo[fieldX]"><div class="smallfont">$userinfo[fieldX]</div></if></td></if>
Change both instances of X to the field number that you specified in the plugin earlier (2).
Final Comment
It's not pretty, it's not clever but it works..