Get current user ID in a PHP hook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TitasB
    Member
    • Aug 2017
    • 31

    Get current user ID in a PHP hook

    Hello,

    how can I get the current user's ID in a PHP hook?
  • alter
    Member
    • Apr 2018
    • 57

    #2
    Hello, example for getting user ID in PHP is in controller in User.php
    $userId = $this->getUser()->id

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3
      The only right answer, is one needs to define \Espo\Entities\User $user as a constructor parameter. The current user will be automatically passed.

      $this->getUser() is not a correct answer.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment


      • rabii
        rabii commented
        Editing a comment
        yes i forgot to mention that
    Working...