View Full Version : "Members who have read thread" question
bazookajoe
06-28-2015, 05:15 PM
Is there a way to display the "members who have read this thread" in alphebetical order rather than random order?
There isn't, but you could add a plugin to sort them. Using hook showthread_whoread_list, you could use code something like this:
if (!function_exists('wrt_compare_username'))
{
function wrt_compare_username($u1, $u2) { return strcmp($u1['username'], $u2['username']); }
}
uasort($wrtlist, 'wrt_compare_username');
(but I haven't tested it at all).
MarkFL
06-28-2015, 06:24 PM
Kevin, that in fact does correctly sort by username, however it does not ensure that all but the last name has a trailing comma. :)
Kevin, that in fact does correctly sort by username, however it does not ensure that all but the last name has a trailing comma. :)
Oh, OK, do you know how to fix it? I just typed it in without even checking to see if it had typos or anything. :) Feel free to post a better one.
MarkFL
06-28-2015, 09:06 PM
I briefly tried earlier, but will give it a better go tonight when I am in for the night. :D
Paul M
06-28-2015, 09:20 PM
If you replace this ;
uasort($wrtlist, 'wrt_compare_username');
With this ;
$wrtlist[$count]['comma'] = $vbphrase['comma_space'];
uasort($wrtlist, 'wrt_compare_username');
$wrtlist[$count]['comma'] = '';
I *think* it will sort out the commas for you.
MarkFL
06-29-2015, 12:36 AM
This is what I wound up doing, only executing the sort if the user can see the data and I wanted a case-insensitive sort as well:
if ($show['wrt'])
{
if (!function_exists('wrt_compare_username'))
{
function wrt_compare_username($u1, $u2) { return strcmp(strtolower($u1['username']), strtolower($u2['username'])); }
}
$wrtlist[count($wrtlist)]['comma'] = ',';
usort($wrtlist, 'wrt_compare_username');
$wrtlist[count($wrtlist)-1]['comma'] = '';
}
I used usort() so that the keys would not be preserved, otherwise you wouldn't know which is last after the sort. :D
--------------- Added 1435563569 at 1435563569 ---------------
I have created a product based off of the ideas in this thread here (thank you Kevin and Paul for your contribution :)):
Sort Who Read Thread Users (https://vborg.vbsupport.ru/showthread.php?t=319283)
That product will allow you to sort the users either by userid, username, or dateline. :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.