Magento: Redirect Customer to Previous Page After Login
By default, customers are redirected to ‘Customer Account Dashboard’ page after login. This feature can be easily changed from Magento configuration settings.
Configuration Settings
Customers will be redirected to previous page after successful login. Hope it helps. Thanks.
Configuration Settings
- Login to admin panel
- Go to System -> Configuration -> CUSTOMERS -> Customer Configuration -> Login Options
- Set: Redirect Customers to Account Dashboard after Loggin in = No
- You can see in comments for this field: Customer will stay on the current page if “No” is selected.
Redirect to customer login page
<?php if(!Mage::helper('customer')->isLoggedIn()) { Mage::getSingleton('customer/session') ->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl()); $this->_redirect('customer/account/login'); } ?>
Show a login link for non-logged in customers
<?php if(!Mage::helper('customer')->isLoggedIn()) { Mage::getSingleton('customer/session') ->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl()); echo '<p>Please <a href="'.Mage::getUrl('customer/account/login').'">Login</a> to view the page.</p>'; } ?>
Customers will be redirected to previous page after successful login. Hope it helps. Thanks.
Kerry
Kerry Page