Question

How can I display customer name in the header after logged in successfully?

Was it helpful?

Solution

Go to your current theme and your current header, some themes uses different headers : app/design/frontend/default/themek/te‌​mplate/page/html/hea‌​der.phtml for exemple then add this:

<?php if ( Mage::getSingleton('customer/session')->isLoggedIn() ): ?>
    <div class="customer-name">    
        <?php echo Mage::getSingleton('customer/session')->getCustomer()->getName(); ?>
    </div> 
<?php endif; ?>

OTHER TIPS

Try this:

EDIT: file location: app/design/frontend/your_package/your_theme/template/page/html/header.phtml

Add these in this file where you want to get the name to be shown.

<?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>

<?php echo Mage::getSingleton('customer/session')->getCustomer()->getName() ?>

<?php endif; ?>

When the customer is logged in, you can get customer session in frontend from any phtml file.

To show customer name in header, you would need to open header.phtml file located at:

app/design/frontend/yourpackage/yourtheme/template/page/html/

folder and write below code where you want to display current logged in customer name:

<?php
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
echo Mage::getSingleton('customer/session')->getCustomer()->getName();
}
?>

Please let me know if you find any problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top