Magento Forum

   
how to redirect to previous page after login
 
Moeed
Member
 
Total Posts:  48
Joined:  2010-10-10
 

Hello all,

I want to redirect my customers to previous page from where they login, not to “user dashboard”. kindly guide me if it is possible.

Thanks and regards

Abdul Moeed

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shahid Sarvani
Member
 
Avatar
Total Posts:  63
Joined:  2009-08-05
 

Please modify the “loginPostAction” function in the following file, because magento doesn’t provide the by default functionality for this feature:

app/code/core/Mage/Customer/controllers/AccountController.php

Please let me know if you need more help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moeed
Member
 
Total Posts:  48
Joined:  2010-10-10
 

Many thanks for your reply.

suppose customer is on “view” page, now i want to redirect him/her towards previous page. which funtion i have to change. kindly guide me.
any code example will be highly appreciated.

Thanks and regards

Shahid Sarvani - 15 December 2010 04:57 AM

Please modify the “loginPostAction” function in the following file, because magento doesn’t provide the by default functionality for this feature:

app/code/core/Mage/Customer/controllers/AccountController.php

Please let me know if you need more help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moeed
Member
 
Total Posts:  48
Joined:  2010-10-10
 

Any one find solution??????????????

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moeed
Member
 
Total Posts:  48
Joined:  2010-10-10
 

why you people don’t like to help :( ......!!!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jagat Kothari
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2009-06-04
INDIA
 

Hi,

Check the following code block

//Check If Customer Is Logged In Or Not.
if (!Mage::getSingleton("customer/session")->isLoggedIn())
{
$session 
Mage::getSingleton("customer/session");
// Store The Current Page Url Where User will be redirected once loggedin
$session->setBeforeAuthUrl(Mage::helper("core/url")->getCurrentUrl());
$customerLoginURL $this->getBaseUrl() . "customer/account/login";
Mage::app()->getFrontController()->getResponse()->setRedirect($customerLoginURL)->sendResponse();
}

Also you can refer this for more info :

http://jagatk.wordpress.com/2010/05/02/magento-custom-redirection/

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jagat Kothari
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2009-06-04
INDIA
 

Please check this as well. I guess this is what you want.

Login to Magento Admin.

Goto System -> Configuration -> Customer Configuration -> Login Options.

In the dropdown there is option of where to redirect customer once they are logged in.

i..e Redirect Customer to Account Dashboard after Logging in or not.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moeed
Member
 
Total Posts:  48
Joined:  2010-10-10
 

Thanks jagat,

i will look into it and then tell you ... grin , thanks for your time.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ayawlex
Jr. Member
 
Total Posts:  3
Joined:  2011-07-29
 
Jagat Kothari - 21 December 2010 12:15 AM

Please check this as well. I guess this is what you want.

Login to Magento Admin.

Goto System -> Configuration -> Customer Configuration -> Login Options.

In the dropdown there is option of where to redirect customer once they are logged in.


i..e Redirect Customer to Account Dashboard after Logging in or not.

i set it to “NO” , when i log in from shopping cart it goes back to the shopping cart page. but other than that, it goes to the dashboard :( .
example : i’m still configuring a bundle product but then decides to log in, it goes to the dashboard, even in the home page, it goes to the dashboard. what’s going on? :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

If you want to redirect to any page(internal, external, referer/previous page) after login. new account creation, logout events then you can use the following commercial module:
http://www.magentocommerce.com/magento-connect/custom-login-redirect-pro.html

Hope this helps you in case of custom url redirection tasks.

Thanks
Regards

 
Magento Community Magento Community
Magento Community
Magento Community
 
Booleanbit
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2012-02-03
 

Hi,

To Redirect to previous page after login. Go to page login.phtml and replace form action i.e. line 40 or if you are using mini login than go to page mini.login.phtml and replace form action i.e. line 28 with the one given here.

Replace this:

<form action="<?php echo $this->getPostActionUrl() ?>" method="post">

With this:

<form action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>" method="post" id="login-form">

Hope this solves the problem.

Thanks
Booleanbit

 
Magento Community Magento Community
Magento Community
Magento Community
 
arafiee
Jr. Member
 
Total Posts:  1
Joined:  2012-10-16
 
Booleanbit - 03 February 2012 11:34 AM

Hi,

To Redirect to previous page after login. Go to page login.phtml and replace form action i.e. line 40 or if you are using mini login than go to page mini.login.phtml and replace form action i.e. line 28 with the one given here.

Replace this:

<form action="<?php echo $this->getPostActionUrl() ?>" method="post">

With this:
<form action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>" method="post" id="login-form">

Hope this solves the problem.

Thanks
Booleanbit

Thank you so much!

I went through 10 different solutions and your is by far the best and easiest method.

smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
meikland
Jr. Member
 
Total Posts:  6
Joined:  2012-09-10
 

I’m dealing with the same issue and trying Booleanbit’s solution, but I’m still going to the account dashboard. Any thoughts on something I may have missed? I have the Customer Configuration Login Option set to No and I replaced line 41 in the code, as that was the line of code that matched what Booleanbit had for line 40. Any help would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top