8.4.2 How to get user name?
Permalink
I'm trying to get a user name. If I use UserInfo, all works fine, but as it's deprecated, when I use getUserInfoObject, it throws an error: "Call to a member function getByID() on null".
Here's the controller's view():
Here's the view.php:
This works:
What am I missing with the getUserInfoObject?
Here's the controller's view():
$this->set('u', new User());
Here's the view.php:
$ui = $u->getUserInfoObject(); echo $ui->getByID($comment->getUID())->getUserName();
This works:
echo \UserInfo::getByID($comment->getUID())->getUserName();
What am I missing with the getUserInfoObject?
The UserInfoObject is not even required.