I want to understand how can I set a custom page when customer logged in?
Solved! Go to Solution.
I have updated my answer, please have a look
Hi @erik_chan,
This one you can do by modifying Magento's
_loginPostRedirect() function of Mage/Customer/controllers/AccountController.php
You can follow this URL to create a custom module to overwrite the above-mentioned core Magento function
http://www.tothenew.com/blog/9255/
or
When customers sign in Magento they will redirect to account’s dashboard page by default. There is no setting in Magento which will let you set your own landing page for the customer after login. If you want to achieve this feature then you need to do some custom coding.
The first step is, create a custom module “local/Intell/Customer” and override “AccountController” of core customer module to your custom module. Following will be the content of your module’s config.xml file (local/Intell/Customer/etc/config.xml):
<?xml version="1.0"?> <config> <modules> <Intell_Customer> <version>1.1.0</version> </Intell_Customer> </modules> <frontend> <routers> <customer> <args> <modules> <intell_customer before="Mage_Customer">Intell_Customer</intell_customer> </modules> </args> </customer> </routers> </frontend> <global> <helpers> <intell> <class>Intell_Customer_Helper</class> </intell> </helpers> </global> </config>
Controller function responsible for customer redirection after login is “_loginPostRedirect “. Override this function to your custom account controller. Following is the code of custom account controller (local/Intell/Customer/controllers/AccountController.php). In this code “$customerRedirectUrl ” contains your custom page URL :
<?php require_once 'Mage/Customer/controllers/AccountController.php'; class Intell_Customer_AccountController extends Mage_Customer_AccountController { protected function _loginPostRedirect() { //customer session $session = $this->_getSession(); $preUrl = $session->getBeforeAuthUrl(true); $cusromerRedirectStatus = 1; //your custom url $customerRedirectUrl = "customer/address/new"; $redirectUrl = $preUrl; if(($cusromerRedirectStatus) && ($customerRedirectUrl) && ($session->getCustomerRedirectFlag()) && (strpos($preUrl, 'checkout/onepage') == '')){ $redirectUrl = Mage::getUrl().$customerRedirectUrl; } if(($cusromerRedirectStatus) && ($customerRedirectUrl)){ $redirectUrl = Mage::getUrl().$customerRedirectUrl; } if ($this->_getSession()->isLoggedIn()) { $this->_redirectUrl($redirectUrl); return; } $this->_redirectUrl($preUrl); } }
The last step is, create a helper (local/Intell/Customer/Helper/Data.php) :
<?php class Intell_Customer_Helper_Data extends Mage_Core_Helper_Abstract { }
And yes, add your module’s pool file in app/etc/modules
<?xml version="1.0"?> <config> <modules> <Intell_Customer> <active>true</active> <codePool>local</codePool> </Intell_Customer> </modules> </config>
Note: Please don't modify code Magento functions and files.
Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.
"
You can follow this URL to create a custom module to overwrite the above-mentioned core Magento function
http://www.tothenew.com/blog/9255/
"
I cannot access this web page
Sorry, I cannot work in it
I want to understand the directory path
Is it...?
app/code/local/intell/Customer/controllers/AccountController.php
app/code/local/intell/Customer/etc/config.xml
app/code/local/intell/Customer/Helper/Data.php
app/etc/modules/Intell_Customer.xml
If yes, why cannot work?
If no, please tell me the right file path
Thanks~
Finally I found a extension to soled it