[Solved] Can't Redirect After Signup

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…

Anyway, do you guys see what I am missing?

Thanks!

try this




return $this->redirect(['register/congratulations']);



Oh my God…it should be that…

Can’t try it right now but tell you later…

It’s so simple… :rolleyes:

Sadly…this didn’t have any effect… :(




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…

Uggh…I am such an ass… :rolleyes:

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…

@Arash26 thanks for your help! :)