I've been trying to get the user id when running a task to save it on a table but cannot find a way to get it not even the user info.
Using Craft::$app->getUser()
or Craft::$app->user
I get:
["_identity":"craft\console\User":private]=>
bool(false)
["_events":"yii\base\Component":private]=>
array(0) {
}
["_eventWildcards":"yii\base\Component":private]=>
array(0) {
}
["_behaviors":"yii\base\Component":private]=>
NULL
which is not good and if I try with Craft::$app->getUser()->getIdentity()
I get an error.
Is there a way to get the user information within a task?.
Thank you for all your help!