I have made a custom module in which I have an observer file. I need to display all information about the logged in user.
2 Answers
Use the event customer_login
:
<customer_login>
<observers>
<yourobservername>
<type>model</type>
<class>yourmodule/path_to_class</class>
<method>customerLogin</method>
</yourobservername>
</observers>
</customer_login>
Your observer class would look like this:
class YourCompany_YourModule_Model_Observer
{
public function customerLogin($observer)
{
$customer = $observer->getCustomer();
}
}
-
1
-
-
Heyy.. I am very new in magento.I also want to do same thing.Can you tell me where i have to put this code in file structure?– HappyAug 7, 2014 at 10:48
-
I want before login action when user login wrong password login. Sep 17, 2014 at 6:56
-
Try This
if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
//for firstname
$customerFirstName = $customerData['firstname'];
}
-
2
Mage::getSingleton('customer/session')->getCustomer()
is enough to get customer details, then why reload customer instance again ? May 17, 2016 at 8:15 -
Yes it is not required . But I edited according to the code flow $customer -> getFirstname() will also work . May 17, 2016 at 9:03