Well…I think I am missing something simple here but can’t find what is it…
I want to redirect the user to a Congratulations page after sign up (and login).
This is the signup action code:
public function actionFill()
{
$model = new SignupPersonForm();
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->register()) { // user saved
Yii::$app->user->login($user); // login is ok here
Yii::$app->session->setFlash('status', 'REGISTRATION_FINISHED'); // some mark for the next page
// The next line never happens
$this->redirect(['register/congratulations']);
} else {
Yii::$app->session->setFlash('warning', 'Problems blah blah.');
}
}
It never goes to my ‘register/congratulations’ page, but to the home page…
I tried setting return url to the desired page before login in but had some strange behavior too…like keeping in the current page…
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->register()) { // user saved
Yii::$app->user->login($user); // login is ok here
Yii::$app->session->setFlash('status', 'REGISTRATION_FINISHED'); // some mark for the next page
// The next line never happens
$this->redirect(['register/congratulations']);
} else {
Yii::$app->session->setFlash('warning', 'Problems blah blah.');
}
}
I guess it has something to do with returnUrl…but can’t find if login() is redirecting by itself…
Besides the problem with lack of the return statement, the access control filter was missconfigured and the keeping returning to home url when the user was logged in…