PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 9, 2022

[FIXED] yii redirect not working

 January 09, 2022     php, url-redirection, yii     No comments   

Issue

In Yii framework $this->redirect function not working.

class TplUserNavigation extends CWidget{

public function run()
    {
        if(isset(Yii::app()->user->id) && Yii::app()->user->getState('userType') == 'User'){
         $users = Users::model()->findByAttributes(array('id'=>Yii::app()->user->id));
         $this->render('webroot.themes.'.Yii::app()->theme->name.'.views.layouts.tpl_navigation', array('users'=>$users));
        }else{
          $this->redirect('site/index'); 
    }
}

Solution

Try:

$this->redirect("site/index"); 

or if you want to redirect to home page:

$this->redirect(Yii::app()->homeUrl);

From CWidget try:

$this->owner->redirect(array("site/index"));

Read more here about redirect from widget.



Answered By - TotPeRo
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing