Magento – How to Get Logged In customer details – Full Name, First Name, Last Name and Email Address
This post is use for get detail of Logged In customer details in Magento. In this post we check Customer is login or not, if Customer is login then we call function get_customer_detail(), It will tack all detail of Logged In Customer.
// function to get user detail function get_customer_detail() { // get current user detail $_customer = Mage::getSingleton('customer/session')->get_customer(); // remove comments for show all detail of Customer // echo "</pre> // print_r($_customer); // echo "</pre>"; // basic detail of customer echo $_customer->getPrefix(); echo $_customer->getName(); // Full Name echo $_customer->getFirstname(); // First Name echo $_customer->getMiddlename(); // Middle Name echo $_customer->getLastname(); // Last Name echo $_customer->getSuffix(); // other customer details echo $_customer->getWebsiteId(); // get ID of website/store echo $_customer->getEntityId(); // get Entity Id echo $_customer->getEntityTypeId(); // get Entity Type Id echo $_customer->getAttributeSetId(); // get Attribute Set Id echo $_customer->getEmail(); // get customer email Id echo $_customer->getGroupId(); // get customer Group Id echo $_customer->getStoreId(); // get customer Store Id echo $_customer->getCreatedAt(); // get Created date(yyyy-mm-dd hh:mm:ss) echo $_customer->getUpdatedAt(); // get getUpdated date(yyyy-mm-dd hh:mm:ss) echo $_customer->getIsActive(); // customer is active 1 or 0(not active) echo $_customer->getDisableAutoGroupChange(); echo $_customer->getTaxvat(); echo $_customer->getPasswordHash(); echo $_customer->getCreatedIn(); // get Created In echo $_customer->getGender(); // get customer Gender echo $_customer->getDefaultBilling(); // get Default Billing echo $_customer->getDefaultShipping(); // get Default Shipping echo $_customer->getDob(); // get customer Dob (yyyy-mm-dd hh:mm:ss) echo $_customer->getTaxClassId(); // get TaxClass Id } // check user is login or not if(!Mage::getSingleton('customer/session')->isLoggedIn()) { get_customer_detail(); } else { echo "user is already login"; }