Display name instead of username in Who is online module

From Joomla! Documentation

Revision as of 06:41, 19 September 2010 by Batch1211 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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


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

This trick was written for Joomla! 1.5.