Display name instead of username in Who is online module

From Joomla! Documentation

Revision as of 06:01, 14 July 2008 by Erdsiger (Talk | contribs)

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';


 $query = 'SELECT DISTINCT' .
   ' FROM #__session AS a' .
   ' INNER JOIN #__users AS u ON = 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; ?>


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

This trick was written for Joomla! 1.5.