/** * Creates a new UserProfile model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UserProfile(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates user profile and application event * @param array $profileData */ public function afterSignup(array $profileData = []) { $this->refresh(); Yii::$app->commandBus->handle(new AddToTimelineCommand(['category' => 'user', 'event' => 'signup', 'data' => ['public_identity' => $this->getPublicIdentity(), 'user_id' => $this->getId(), 'created_at' => $this->created_at]])); $profile = new UserProfile(); $profile->locale = Yii::$app->language; $profile->load($profileData, ''); $this->link('userProfile', $profile); $this->trigger(self::EVENT_AFTER_SIGNUP); // Default role $auth = Yii::$app->authManager; $auth->assign($auth->getRole(User::ROLE_USER), $this->getId()); }