我在Joomla 2.5.16上,我想要当前的用户ID和组ID。
以下代码返回空白页面,为什么?
<?php
include_once $_SERVER['DOCUMENT_ROOT']."/includes/defines.php";
include_once $_SERVER['DOCUMENT_ROOT']."/includes/framework.php";
$user = JFactory::getUser();
$group_id = &JFactory::group_id();
$user_id = $user->get('id');
echo $user_id;
echo $group_id;
?>
答案 0 :(得分:0)
试试这个
$user =& JFactory::getUser();
if (!$user->guest) {
echo 'You are logged in as:<br />';
echo 'User name: ' . $user->username . '<br />';
echo 'Real name: ' . $user->name . '<br />';
echo 'User ID : ' . $user->id . '<br />';
}