Reputation: 10624
I'm using Magento 1.7 and I would like to redirect all my clients after login to the home page.
I'm using the extension to close the site to non logged in users. I'm not using the default login page, but a CMS page with a facebook connect button.
Right now, after the user logs in with facebook, magento is loading the same page without the facebook connect button.
I have seen this thread, but did not find the AccountManager to modify it. Where is it? Also, I'm not sure that this would work, since the redirection in my case is not happening to the customer's dashboard, but to the cms page I created.
How (and where in the code) can I check if a user is logged in and redirect him/her to the home page?
Thanks in advance
Upvotes: 1
Views: 5920
Reputation: 478
One approach would be to hook onto the **customer_login**
event and set the afterAuthUrl in the customer session.
...
public function customerLogin(Varient_Event_Observer $observer) {
/* @var $session Mage_Customer_Model_Session */
$session = Mage::getSingleton('customer/session');
$session->setAfterAuthUrl(Mage::getBaseUrl());
}
You can view Magento's logic in the AccountController
_loginPostRedirect
method (app/code/core/Mage/Customer/controllers/AccountController.php)
. Based on the implementation you'll notice it is also possible to send a referrer request parameter (note: it must be base64
encoded via Mage::helper('core')->urlEncode())
.
Upvotes: 5
Reputation: 4559
using event as mentioned by @beep logic with method from customer session Mage::getSingleton('customer/session')->setBeforeAuthUrl($url);
helped in redirection to desired page.
Hope this helps
Upvotes: 0
Reputation: 523
I believe that there is an extension made by AITOC that does what you are trying to do. In case you're interested in purchasing rather than building.
Upvotes: 0