/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * User registration action * * @return mixed */ public function actionRegister() { $config = $this->module->registrationSettings; if (!$config['enabled']) { return $this->goBack(); } $model = new User(['scenario' => Module::UI_REGISTER]); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($config['autoActivate']) { $model->setStatus(User::STATUS_ACTIVE); $model->save(); Yii::$app->session->setFlash("success", Yii::t('user', Module::MSG_REGISTRATION_ACTIVE, ['username' => $model->username])); return $this->goHome(); } else { $model->save(); if ($model->sendEmail('activation')) { Yii::$app->session->setFlash("success", Yii::t('user', Module::MSG_PENDING_ACTIVATION, ['email' => $model->email])); } else { Yii::$app->session->setFlash("warning", Yii::t('user', Module::MSG_PENDING_ACTIVATION_ERR, ['email' => $model->email])); } } } return $this->render(Module::UI_REGISTER, ['model' => $model, 'config' => $config]); }