title: TYPO3 - how to get FE UID via Viewhelper
body: <p>How can I fetch and render the uid of the FE User via a Viewhelper? The below is working via a Controller ... but not in a Viewhelper. Where is the difference? I'm using 7.6.11 and at the end I would like to have the uid of the FE User and the usergroup uid of him and further use it in the html of the extension and in general partials ...  </p>
  
  <p>/typo3conf/ext/extension/Classes/ViewHelpers/UserViewHelper.php</p>
  
  <pre><code>&lt;?php
  
  namespace Vendor\Extension\ViewHelpers;
  
  class UserViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
  
  /**
  * User Repository
  *
  * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
  * @inject
  */
  protected $userRepository;
  
  /**
  * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository
  * @inject
  */
  protected $frontendUserGroupRepository;
  
  public function render() {
  
      $userIDTest = $this-&gt;userRepository-&gt;findByUid($GLOBALS['TSFE']-&gt;fe_user-&gt;user['uid']); 
      $this-&gt;view-&gt;assign('userIDTest', $userIDTest);
  
  }   
  
  }
  </code></pre>
  
  <p>List.html</p>
  
  <pre><code>&lt;f:layout name="Default" /&gt;
  &lt;f:section name="main"&gt;
  
      {userIDTest.uid}
  
  &lt;/f:section&gt;
  </code></pre>
  
  <p>As suggested by Dimitry I replaced </p>
  
  <pre><code>$this-&gt;view-&gt;assign('userIDTest', $userIDTest);
  </code></pre>
  
  <p>with </p>
  
  <pre><code>return $userIDTest;
  </code></pre>
  
  <p>And in List.html I have this: </p>
  
  <pre><code>{namespace custom=Vendor\Extension\ViewHelpers}
  
  &lt;f:layout name="Default" /&gt;
  &lt;f:section name="main"&gt; 
  
  &lt;f:alias map="{user: '{custom:user()}'}"&gt;
      {user.uid} {user.username}
  &lt;/f:alias&gt;
  
  &lt;/f:section&gt;
  </code></pre>
  
  <p>... and after clearing all Caches (FE/BE/Install) and deleting typo3temp ... now its working!</p>