How to get user object in widget


#1

How to get user object in widget?

getUser() in widget controller doesn’t work. It return false.

Only way is pass userId or user object as parameter to widget?


#2

are you logged in?


#3

yes i am logged in


#4

in this case it actually should work.
try adding [{$oxcmp_user|@var_dump}] into widgets template to see if user object is available there


#5
  1. Yes oxcmp_user works in widget template.

  2. When i try to dump($oUser->isLoaded) after $this->getUser() in widget controller it throws me an error:

[12 Apr 13:51:40.494988 2018] [uncaught error] [type E_ERROR] [file /var/www/kiratest01/vendor/oxid-esales/oxideshop-ce/source/Core/Exception/ExceptionHandler.php] [line 114] [code ] [message Uncaught TypeError: Argument 1 passed to OxidEsales\EshopCommunity\Core\Exception\ExceptionHandler::handleUncaughtException() must be an instance of Exception, instance of Error given in /var/www/kiratest01/vendor/oxid-esales/oxideshop-ce/source/Core/Exception/ExceptionHandler.php:114
Stack trace:
#0 [internal function]: OxidEsales\EshopCommunity\Core\Exception\ExceptionHandler->handleUncaughtException(Object(Error))
#1 {main}
thrown]