我正在制作一个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;
}
}
?>
我该怎么做?
尝试返回$name; 而不是回显$name;
它应该是:
$cuser = CFactory::getUser();
$name = $cuser->getDisplayName();
echo $name;