_user = User::findByVerificationToken($token); if (!$this->_user) { throw new InvalidArgumentException('Wrong verify email token.'); } parent::__construct($config); } /** * Verify email * * @return User|null the saved model or null if saving fails */ public function verifyEmail() { $user = $this->_user; $user->status = User::STATUS_VERIFIED; Yii::$app->queue->push(new EmailJob([ 'templateAlias' => EmailJob::ADMIN_NOTIFY, "email" => Yii::$app->params['adminEmail'], 'templateModel' => [ "user_name" => $user->email, "action_url" => Yii::$app->urlManager->createAbsoluteUrl(['user/update', 'id' => $user->id, 'approve' => 1]), "action_edit_url" => Yii::$app->urlManager->createAbsoluteUrl(['user/update', 'id' => $user->id]), ] ])); return $user->save(false) ? $user : null; } }