echo在JomSocial插件中不起作用

时间:2014-12-16 09:22:52

标签: jomsocial

我正在创建一个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;
    }
}

?>

我该怎么做?

2 个答案:

答案 0 :(得分:0)

尝试返回$ name;而不是echo $ name;

答案 1 :(得分:0)

应该是:

$cuser  = CFactory::getUser();
$name = $cuser->getDisplayName();
echo $name;