Announcement

Collapse
No announcement yet.

Get current user ID in a PHP hook

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get current user ID in a PHP hook

    Hello,

    how can I get the current user's ID in a PHP hook?

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

    Comment


    • #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.

      Comment


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