Difference between revisions of "Display name instead of username in Who is online module"

From Joomla! Documentation

 
(2 intermediate revisions by 2 users not shown)
Line 33: Line 33:
  
 
[[Category:Tips and tricks]]
 
[[Category:Tips and tricks]]
 +
[[Category:Tips and tricks 1.5]][[Category:User Management]]

Latest revision as of 07:41, 19 September 2010

If you want to display the name of the user instead of the username in the Who is online module, you need to do the following steps. The module gets the data from the session table, but that table doesn't contain the name of the user, only the username and the userid. That's why you need to join the session and the users table in the sql query. For this open the /modules/mod_whosonline/helper.php file and change

$query = 'SELECT DISTINCT a.username' .
  ' FROM #__session AS a' .
  ' WHERE client_id = 0' .
  ' AND a.guest = 0';

to

$query = 'SELECT DISTINCT u.name' .
  ' FROM #__session AS a' .
  ' INNER JOIN #__users AS u ON u.id = a.userid' .
  ' WHERE a.client_id = 0' .
  ' AND a.guest = 0';

There is only one step left, open the /modules/mod_whosonline/tmpl/default.php file and at the bottom change

<?php echo $name->username; ?>

to

<?php echo $name->name; ?>

This trick was written for Joomla! 1.5.