Before geting the details of a customer you must to have check whether Customer is Logged in or not, If a customer is logged in then only you can get details fo the customer. To check whether user logged in or not click here or you can go to http://xhtmlandcsshelp.blogspot.com/2010/11/magento-check-if-user-logged-in-or-log.html to get the code. Then write the code below to get customer details
$customer = Mage::getSingleton('customer/session')->getCustomer();
$email = $customer->getEmail();// To get Email Id of a customer
$firstname = $customer->getFirstname();// To get Firstname of a customer
$lastnam e= $customer->getLastname();// To get Last name of a customer
来源: http://xhtmlandcsshelp.blogspot.com/2011/03/get-customer-details-in-magento-how.html
Get the logged in customer details like customer id, name, email, etc.
$customer = Mage::getModel('customer/customer')->load(1)->getData(); print_r($customer);
Output:
Array ( [entity_id] => 1 [entity_type_id] => 1 [attribute_set_id] => 0 [website_id] => 1 [email] => john.doe@example.com [group_id] => 1 [increment_id] => 000000001 [store_id] => 1 [created_at] => 2007-08-30 23:23:13 [updated_at] => 2008-08-08 12:28:24 [is_active] => 1 [firstname] => John [lastname] => Doe [password_hash] => 204948a4020ed1d0e4238db2277d5:eg [prefix] => [middlename] => [suffix] => [taxvat] => [default_billing] => 274 [default_shipping] => 274 )
Getting customer firstname.
$customer = Mage::getModel('customer/customer')->load(1); $customerFirstName = $customer->getFirstname();
Similarly, we can get lastname, email, etc. ( [website_id] = getWebsiteId() )
来源: http://ka.lpe.sh/2011/06/19/magento-get-customer-details-customer-id-name-email/
echo $this->helper('customer')->getCustomerName(); // echo $customerName = Mage::helper('customer')->getCustomerName();
或者
echo "<pre>"; print_r($this->helper('customer')->getCustomer()->getData()); echo "</pre>"; //echo "<pre>"; print_r(Mage::helper('customer')->getCustomer()->getData()); echo "</pre>";
来源: http://stackoverflow.com/questions/416553/current-user-in-magento