i have installed yii user and rights and upon login through "webapp/user/login" it directs me to the index.php page. i want to direct admin to another page rather then index.php page. which file would i need to edit to direct admin to the desired page. Help needed.
Asked
Active
Viewed 51 times
0
-
show site controller. where you have the action login – ScaisEdge Nov 08 '15 at 16:20
-
I have posted an answer in the code there are comment for explai where redirect or render to the page you want. – ScaisEdge Nov 08 '15 at 16:29
-
i am using yii user and right extension. well upon login i from the url "webapp/user/login" i want to go the page webapp/story/create. how can i write this in the code you have mentioned. – Salik Asad Nov 08 '15 at 18:01
1 Answers
1
you should have this code in you site/controller
/**
* Displays the login page
*/
public function actionLogin()
{
$model=new LoginForm;
// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
//
//this if you want redirect to returnUrl (index.php by default)
// here you can change redirect to url you prefer
// or render proper page
// $this->redirect(Yii::app()->user->returnUrl);
// this for your destination
$this->redirect(array('story/create'));
}
// display the login form
$this->render('login',array('model'=>$model));
}

ScaisEdge
- 131,976
- 10
- 91
- 107
-
i am using yii user and right extension. well upon login i from the url "webapp/user/login" i want to go the page webapp/story/create. how can i write this in the code you have mentioned above. – Salik Asad Nov 08 '15 at 17:39
-
mate it isn't redirecting me from "webapp/user/login" to "webapp/stroy/create" instead of this from "webapp/site/login" it is redirecting me to "webapp/story/create" – Salik Asad Nov 08 '15 at 18:08
-
-
I don't understand you goal please explain better. I think you after login want go to story/create ... – ScaisEdge Nov 08 '15 at 18:13
-
i guess i am confusing between site/login and user/login i guess both are the same things, am i right..?? – Salik Asad Nov 08 '15 at 18:18
-
The login is One only. Site login is the controller for this action. But you can check. – ScaisEdge Nov 08 '15 at 18:26
-
For check go to the layout (main.php in view/layout) you can see the controller/action call by login. – ScaisEdge Nov 08 '15 at 18:29
-
i have another ques. this is the link, please try to answer http://stackoverflow.com/questions/32272633/show-logout-button-along-with-the-name-of-user-after-successfull-login – Salik Asad Nov 08 '15 at 18:35
-
-
oh sorry, i gave u the wrong link, here is the correct one..!! http://stackoverflow.com/questions/33597530/yii-upon-login-show-the-username-and-logout-button the link before was just for reference. – Salik Asad Nov 08 '15 at 18:54
-
hi @scaisEdge, can you please help me with this. http://stackoverflow.com/questions/33610115/yii-redirecting-the-admin-and-authenticated-user-to-the-desired-page – Salik Asad Nov 09 '15 at 13:25
-
Hi @scaisEdge, can u please look into this.. https://stackoverflow.com/questions/33639931/yii-the-system-is-unable-to-find-the-requested-action-select – Salik Asad Nov 10 '15 at 21:39