[SOLVED] Need help editing listusers.php in admin

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
sugna
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 10, 2007 3:04 pm

[SOLVED] Need help editing listusers.php in admin

Post by sugna »

Version 1.4.1

I want to change the way the Users display when viewing User's in the Admin.

I want to:

Display the Users by last name and first name

This works but need to know how to put a space in between last name and first name

Code: Select all

echo "<td><a href=\"edituser.php?user_id=".$oneuser->id."\">".$oneuser->lastname , $oneuser->firstname."</a></td>\n";
Display the list in alpha order

I tried this but no luck ordering by lastname in Alpha order Example abcde etc.

Code: Select all

$query = "SELECT user_id, username, active FROM ".cms_db_prefix()."users ORDER BY username";
Thanks all for your help,

Shane
Last edited by sugna on Sat Oct 11, 2008 2:26 pm, edited 1 time in total.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Need help editing listusers.php in admin

Post by Dee »

sugna wrote: This works but need to know how to put a space in between last name and first name

Code: Select all

echo "<td><a href="edituser.php?user_id=".$oneuser->id."">".$oneuser->lastname , $oneuser->firstname."</a></td>\n";

Code: Select all

echo "<td><a href="edituser.php?user_id=" . $oneuser->id . "">" . "$oneuser->lastname $oneuser->firstname</a></td>\n";
or

Code: Select all

echo "<td><a href="edituser.php?user_id=" . $oneuser->id . "">" . $oneuser->lastname . ' ' . $oneuser->firstname . "</a></td>\n";
sugna wrote: Display the list in alpha order

I tried this but no luck ordering by lastname in Alpha order Example abcde etc.

Code: Select all

$query = "SELECT user_id, username, active FROM ".cms_db_prefix()."users ORDER BY username";
It looks like you're ordering by username instead of lastname, try:

Code: Select all

$query = "SELECT user_id, username, active FROM ".cms_db_prefix()."users ORDER BY lastname";
Grtz,
D
User avatar
sugna
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 10, 2007 3:04 pm

Re: Need help editing listusers.php in admin

Post by sugna »

Thanks Dee,

Question two not solved.

This

Code: Select all

$query = "SELECT user_id, username, active FROM ".cms_db_prefix()."users ORDER BY lastname";
Won't display the users in alpha order for some reason. I would expect it to.

Does something else control the display. Reason why I ask is because the firstname is in Alpha order

Question one is solved.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Need help editing listusers.php in admin

Post by Dee »

Hmmm, it seems the query in listusers.php is executed but not used at all - the userlist is aquired using $userops->LoadUsers();

To order the users by lastname edit the file classes/class.useroperations.inc.php and change the query on line 46:

Code: Select all

$query = "SELECT user_id, username, password, first_name, last_name, email, active, admin_access FROM  ".cms_db_prefix()."users ORDER BY lastname";
Regards,
D
User avatar
sugna
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 10, 2007 3:04 pm

Re: Need help editing listusers.php in admin

Post by sugna »

Thanks Dee,

Presto! [SOLVED] one note the row would be "last_name" not lastname for anyone else that wants t do this.


So the q is

Code: Select all

$query = "SELECT user_id, username, password, first_name, last_name, email, active, admin_access FROM ".cms_db_prefix()."users ORDER BY last_name";
Thanks Dee
Post Reply

Return to “CMSMS Core”