我想获取用户的用户组。我使用以下代码:
$CurrentUser =& JFactory::getUser();
print_r($CurrentUser->groups);
现在,在Joomla的1.5版本中,它打印出这个数组:
数组 ( [已注册] => 2 [作者] => 3 [RBGS_RBS_U15_Trainer] => 1063 )
在 v2.5 中,我得到了这个:
数组 ( [2] => 2 [3] => 3 [1063] => 1063 )
那么在 v2.5 中是否有可能获取用户组的名称?
提前感谢,
恩恩
好吧,答案是更改一行代码。浏览到libraries/joomla/database/table/user.php。在那里,更改行
$this->groups = $this->_db->loadAssocList('id', 'id');
自
$this->groups = $this->_db->loadAssocList('title', 'id');
它应该有效。