Home Redirect User login to diffrent page based on model view id Yii2
Reply: 0

Redirect User login to diffrent page based on model view id Yii2

imtrying
1#
imtrying Published in 2017-12-06 08:04:59Z

Hello i have question about redirect user after login, im using Yii2 Advanced

the condition is: 1. i have 2 user first user A and user B 2. if i logged as User A it will redirect for example

user A will redirect into ID Employee = 1

backen/web/index.php?r=Employee%2Fview&id=1

and User b it will redirect into ID Employee = 2

backend/web/index.php?r=employee%2Fview&id=2

this is my Login Controller

 public function actionLogin() {
        if (!Yii::$app->user->isGuest) {
            return $this->goHome();
        }

        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->redirect('index.php?r=employee%2Fview&id=2');
        } else {
            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }

but all of login user will redirect into View id=2, i really appreaciate any help. Thanks advanced

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.570609 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO