Hello Community,
I Will Try to create an observer after customer login, but does not workings, and i cant find why .
Here is my code files
/etc/modules/Kbs_Changegroup.xml
<?xml version="1.0"?> <config> <modules> <Kbs_Changegroup> <active>true</active> <codePool>local</codePool> </Kbs_Changegroup> </modules> </config>
/app/code/local/Kbs/Changegroup/etc/config.xml
<?xml version="1.0"?> <config> <modules> <Kbs_Changegroup> <version>0.1</version> </Kbs_Changegroup> </modules> <global> <models> <kbs_changegroup> <class>Kbs_Changegroup_Model</class> </kbs_changegroup> </models> </global> <frontend> <events> <customer_before_login> <observers> <kbs_changegroup_customer_login> <type>singleton</type> <class>kbs_changegroup/observer</class> <method>customerLogin</method> </kbs_changegroup_customer_login> </observers> </customer_before_login> </events> </frontend> </config>
/app/code/local/Kbs/Changegroup/Model/Observer.php
class Kbs_Changegroup_Model_Observer { public function customerLogin($observer) { if ($customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId()) == "4") { $url = "url"; MAGE::log($url." after log in"); Mage::app()->getResponse()->setRedirect($url); } else { ///// do something else } } }
Any idea What is wrong here;
Hi @karabillys,
I guess that you've copied that code from some post out there.
The customer_before_login event isn't an out-of-hte-box event in Magento.
Also, if you're trying to apply an observer to that event, is happening before the login so you won't get the customer information from session because wasn't set yet.
Maybe you can try listening the customer_login event (I didn't tried but has more sense).
Hi @Damian Culotta,
Thank you for your answer ,
So you suggest me to make the event after login to take the customer information?
i will try the customer_login event.
thank you again.