how to change default return url for login action

hi every one ,

i am a bit confusing about a webuser return url in yii..

i want to redirect my all user on the default page like edit profile rather then index.php …

i am using this syntex in my login action …


its working fine but the only issue is there i want to change a default return url…

all i want is that i want to redirect all user on their edit profile page when they login from sign up page…and return them on a same page from login required page…!!

i know that i have to just change a default return url…but dont know how to do it…!!! :(

i have already read this thread.

retun url is index.php

but couldn’t get anything.that is why i start a new thread here.

anybody can rid me off from this problem.

thanks in advance…!!

hi i had the same issue i used


to set the return url to user profile

and in the site controller actionLogin i used

if($model->validate() && $model->login()){







this worked for me hope it will help you.

would you please tell me where you add this piece of code…!! because it is not clear to me yet.

because i am getting this error after implementing you code…

error:-Only variables should be passed by reference

could you please tell me in which file i have to add this code…

first i was using this on the controllers where i needed to set the return url such as when someone try to edit his profile with out login the in the update controller of profile i used this





         // code  


but then i noticed that there is no need to set url in this case because the yii already sets the return url so i removed it but it worked for me on different controllers

currently i m using this to redirecting to the users profile page by default when user is logged in



i m passing an id to the profile action to show that user profile

thanks Shahzad ,

i’ve just added a condition in login action as mentioned by you and yes its work for me…

thank you again.!! :)

you are welcome