1

如何从站点前端或管理后端找出用户登录。

有没有办法找出用户登录?

4

1 回答 1

1

试试这样,我想它可以帮助你。

<?php

$db = JFactory::getDbo();
$user = JFactory::getUser();

$query = $db->getQuery(true);
$query->select('s.time, s.client_id, u.id, u.name, u.username');
$query->from('#__session AS s');
$query->leftJoin('#__users AS u ON s.userid = u.id');
$query->where('s.guest = 0');
$db->setQuery($query);
$users = $db->loadObjectList();

foreach ($users as $user)
{
    if($user->client_id) {
        echo JText::_('JADMINISTRATOR');
    } else {
        echo JText::_('JSITE');
    }
}
?>
于 2012-10-03T08:15:33.237 回答