How to get User id in Shell

I am saving records to the database from a shell and I need to set current user id before save.
Or should I call a controller action?

You’ll need to pass the user id into the shell as a parameter. Shells aren’t run in a “request”, or authenticated context and so have no concept of users.

1 Like