Joomla: Who’s Online Module – wrong number of guests

If you find that the “Who’s online module” is showing more users online that actually is this should fix it.

Go to > /modules/mod_whoisonline/helper.php

Change:
$query = ‘SELECT guest, usertype, client_id’ .
‘ FROM #__session’ .
‘ WHERE client_id = 0′;

To:
$datenow = date(“Y-m-d H:i:s”);
$time_string = strtotime($datenow);
// Modified query below to only show members/users active in the last 10 minutes
$extra_time = 600; //example: 10 min x 60 sec
$online_time = ($time_string-$extra_time);

$query = “SELECT a.guest, a.usertype, a.client_id”
.”\n FROM #__session AS a”
.”\n WHERE a.client_id=0 AND a.time>’$online_time’”;

Now Change:
$query = ‘SELECT DISTINCT a.username’ .
‘ FROM #__session AS a’ .
‘ WHERE client_id = 0′ .
‘ AND a.guest = 0′;

To:
$datenow = date(“Y-m-d H:i:s”);
$time_string = strtotime($datenow);
// Modified query below to only show members/users active in the last 10 minutes
$extra_time = 600; //10 min x 60 sec
$online_time = ($time_string-$extra_time);

// New Query below to only show members/users active in the last 10 minutes
$query = “SELECT DISTINCT a.username, a.userid, u.name”
.”\n FROM #__session AS a, #__users AS u”
.”\n WHERE (a.userid=u.id) AND (a.guest = 0) AND (NOT ( a.usertype is NULL OR a.usertype = ” )) AND a.time>’$online_time’”
.”\n ORDER BY “.(($ueConfig['name_format'] > 2) ? “a.username” : “u.name”).” ASC”;

Share
This entry was posted in Joomla. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free