我正在创建一个JomSocial插件来获取用户名,但是当我回显名称时,它没有显示名称。这是我的代码
<?php
defined('_JEXEC') or die('Restricted access');
require_once JPATH_ROOT .'/components/com_community/libraries/core.php';
class plgCommunityName extends JPlugin{
function getUserDetails(){
$cuser = CFactory::getUser();
$name = $cuser->username;
echo $name;
}
}
?>
我该怎么做?
答案 0 :(得分:0)
尝试返回$ name;而不是echo $ name;
答案 1 :(得分:0)
应该是:
$cuser = CFactory::getUser();
$name = $cuser->getDisplayName();
echo $name;