On a current project, I had a requirement to redirect to the homepage once a user successfully logs in to their account. I tried a few plugins to no avail, so had a go doing it myself. Obviously Magento by default, redirects to the customers Account page although there is a setting in the admin to turn this off. However, this resorts back to redirecting the user to the previous page, ie the referred page.
To redirect to the homepage takes a few more steps, but here’s how I did it.
Go to
admin > System > Configuration > customer configuration > Login Options >
and set “Redirect Customer to Account Dashboard after Logging in” to No.
Then open
\app\code\core\Mage\Customer\controllers\AccountController.php
Look around line 193:
Mage::helper('customer')->getAccountUrl()
is the redirection url to customer dashboard. Change this to your desired URL.
So, for example, you can change it from this:
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
To this:
$session->setBeforeAuthUrl(Mage::getBaseUrl());
…which will redirect your customers to homepage after a successful login.
Hope this helps!
perfect, thanks! works as expected (Magento 1.9.2.2)
Glad it worked out David.
Hi Phil,
how to do this in Magento 2,?
Not used Magento 2 personally, so can’t really help this time.
Thanks it works perfect for 1.9.2.4.
hello thank you so much. But I need to check condition (if cart contains items) means go to (checkout page) after login or if (cart is empty) my (account page)
Thanks. it works