Helpful Information
 
 
Category: vBulletin 3 Discussion
custom sort of the memberlist

The hyperlink for listing members by a particular field is, for example

quote:
--------------------------------------------------------------------------------
http://xxx/forums/memberlist.php?s=&what=field1
--------------------------------------------------------------------------------

I have added three custom fields to my user table, and will display those on the memberlist. (For example, firstname, lastname, graduationyear)

I would like rewrite the hyperlink for the "members" button, so that, when clicked, the resulting list is sorted by
1st - graduationyear
2nd - lastname
3rd - firstname

Can anyone tell me what my hyperlink should look like?

OK; I've determined that what I really should be changing in the code in memberlist.php

I did this:
$orderby=gradyear;

and it worked

However, I don't know the syntax for adding additional fields. Can anyone help me?

I've tried
$orderby=gradyear,lastname,firstname;
and
$orderby=gradyear and lastname and firstname;

And neither worked.

Did you try

$orderby=gradyear&$orderby=lastname&$orderby=firstname

That produced the following error:

Invalid SQL: SELECT *
FROM user,userfield
WHERE 1=1 AND
user.userid = userfield.userid
AND usergroupid NOT IN (1,3,4)
ORDER BY d`````a` ASC
LIMIT 0,1000
mysql error: You have an error in your SQL syntax near '````a` ASC
LIMIT 0,1000' at line 6

mysql error number: 1064

What is the full link you were using that worked? Adn what are the names of the fields you added to the db for the variables?

The hyperlink to the memberlist is the standard link
http://mysite.net/forums/memberlist.php?s=

I added the following fields to the db:
gradyear
firstname
lastnameold
and I modified register.php and registeradult template to force new users to provide that info. I've tested that out, no problems there.

I changed code in memberlist.php from:

if ($orderby=="" or ($orderby!="username" and $orderby!="posts" and $orderby!="joindate" and $orderby!="lastpost")) {
$orderby=username;

to:

if ($orderby=="" or ($orderby!="username" and $orderby!="posts" and $orderby!="joindate" and $orderby!="lastpost" and $orderby!="lastnameold")) {
$orderby=gradyear;

and that works fine also, but it only sorts by gradyear.

I am displaying the memberlist
1st column gradyear
2nd column lastnameold
3rd column firstname
4th column username
etc.

When I signup test users from the same year, Jones and Adams from 1988 are listed before the 1992 people, but Jones gets listed before Adams.

I'm just guessing here but see if this will work.

if ($orderby=="" or ($orderby!="username" and $orderby!="posts" and $orderby!="joindate" and $orderby!="lastpost" and $orderby!="lastnameold")) {
$orderby=gradyear;
$orderby=lastnameold;
$$orderby=firstname;
$orderby=username;

or however order you wanted. Let me know if this does anything.

What happens here is that it just skips right down to the last orderby and sorts by the username. Thanks for your help. I am going to give up for the day.










privacy (GDPR)