Category: X-Cart Tutorials
Posted: Feb 2, 2010
Synopsis: This free x-cart mod will display the user names for those customers who are logged in.
X-Cart's built in "Who's Online" module provides little detail beyond how many people are currently on your x-cart store. The following change will display the user names for those customers who are logged in. For developers, the code can be extended using the login name value to query information from other areas of the x-cart database.
Open modules/Users_online/users_online.php
FIND:
$smarty->assign("users_online", $users_online);
BEFORE ADD:
// WCM - Retrieve user names for the administrator
if ($login != "" && ($current_area == "A" OR ($current_area == "P" && $active_modules['Simple_Mode']))) {
unset($wcmUOLogins);
$wcmUODetails = func_query("SELECT s.data, uo.usertype FROM $sql_tbl[sessions_data] as s, $sql_tbl[users_online] as uo WHERE s.sessid=uo.sessid AND uo.is_registered='Y' ORDER BY usertype");
if (is_array($wcmUODetails) && !empty($wcmUODetails)) {
foreach ($wcmUODetails as $k => $v) {
$wcmUOLogin = "";
$wcmUOStyle = "";
$wcmTempData = unserialize($v['data']);
if ($v['usertype'] == "P" or $v['usertype'] == "A") { $wcmUOStyle = "font-weight: bold"; }
$wcmUOLogin = "<a href='user_modify.php?user=" . $wcmTempData['login'] . "&usertype=" . $v['usertype'] . "' style='" . $wcmUOStyle . "'>" . $wcmTempData['login'] . "</a>";
$wcmUOLogins[] = $wcmUOLogin;
}
}
$wcmUOLogins = implode($wcmUOLogins,", ");
$smarty->assign("wcmUOLogins", $wcmUOLogins);
}
// / WCM - Get logged in users usernames
Open /skin1/modules/Users_online/menu_users_online.tpl
FIND:
{/foreach}
AFTER ADD:
{if $wcmUOLogins ne ""}({$wcmUOLogins}){/if}