The question:
I have made a custom module in which I have an observer file. I need to display all information about the logged in user.
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
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();
}
}
Method 2
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'];
}
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0