0

我在 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;


?>
4

1 回答 1

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 />';
}
于 2013-11-09T22:35:19.387 回答