Answer the question
In order to leave comments, you need to log in
Yii2 how to login user with status not 10?
By default, after registration, the status field is filled => 10, introduced a new status => 3 - awaiting moderation. The user should have the same capabilities as with status 10. But after logging in, it does not give any errors, but does not log in. Where can you dig it?
In the User model
public static function findByUsername($username)
{
return static::findOne(['username' => $username]);
}
Answer the question
In order to leave comments, you need to log in
So add a condition so that it looks for users with status 10 and 3.
return static::findOne(['username' => $username, [
'or', ['status' => self::STATUS_ACTIVE], ['status' => self::STATUS_MODERATE]
]]);
['status', 'default', 'value' => self::STATUS_ACTIVE],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question