zu3i4ot
(Zu3i4ot)
1
hi,
i want to check if the returnUrl exists or not and do according to that
for example if the user login first time it should be redirected to is homepage and if it is redirected to the page it is redirected from
by default the yii does the 2nd part
im current confused
if($model->validate() && $model->login()){
if(!Yii::app()->user->returnUrl){
Yii::app()->user->setReturnUrl(array('user/home').'?id='.Yii::app()->user->id);
}
$this->redirect(Yii::app()->user->returnUrl);
}
im using this and can’t figure out how to resolve it.
any help?
mikl
(Mike)
2
if ($model->validate() && $model->login())
$this->redirect(Yii::app()->user->getReturnUrl(Yii::app()->homeUrl));
Check the manual for CWebUser::getReturnUrl.
zu3i4ot
(Zu3i4ot)
3
done it like this it works
if($model->validate() && $model->login()){
Yii::app()->user->setReturnUrl(array('user/home','id'=>Yii::app()->user->id));
$this->redirect(Yii::app()->user->returnUrl);
}
u can use it like this too
if($model->validate() && $model->login()){
$this->redirect(array('user/home','id'=>Yii::app()->user->id));
}
zu3i4ot
(Zu3i4ot)
4
done something like this now
if($model->validate() && $model->login()){
if( strpos(Yii::app()->user->returnUrl,'/index.php')){
$this->redirect(array('user/home','id'=>Yii::app()->user->id));
}else{
$this->redirect(Yii::app()->user->returnUrl);
}
}
i have one problem now that now i want registered user don’t see login or signup page if they try to do it by editing the url like: site/login
how to do that?
Like this?
public function actionLogin()
{
if (!Yii::app()->user->isGuest)
$this->redirect(Yii::app()->user->returnUrl);
....
}