3

So I'm running into an issue where I'm given the users email. From there, I use the following code: Craft::$app->getUsers()->getUserByEmail($email);. This returns a null value, not because the user does not exists, but rather the status is set to suspended.

Is there a way to retrieve the User model from the email address, regardless of status?

2

Something like this should work:

$user = User::find()
    ->email($email)
    ->status(null)
    ->one();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.