Categories
Magento

Display Current User Name in Magento Stores

Magento content management is an advanced eCommerce CMS for designing and developing online portals. It can be used to maintain a shopping cart for multiple customers. But is it possible to customize it to display current user name in Magento, once he/she is logged into the account?

Yes, by making a small modification in the codes, we can show the current user’s name. This post will cover how to display the current user name in Magento.

Code to Display Current User Name in Magento

Follow the steps to display current user name in Magento run website.

Use the following code in app/code/core/Mage/Page/Block/Html/Header.php.

public function getWelcome()
{ if (empty($this->_data['welcome'])) {
if (Mage::app()->isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_data['welcome'] = $this->__('Welcome, %s!', Mage::getSingleton('customer/session')->getCustomer()->getName());
} else {
$this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');    }  }
return $this->_data['welcome']; }
Search for the line: Mage::getSingleton('customer/session')->getCustomer()

This will display the name of the current user who is logged in.

To Display Current User Name in Magento Admin

For displaying the current user name logged inside Magento backend, use Mage::getSingleton(‘admin/session’)->getUser();

If you face any sort of difficulties in displaying the user’s name then request a quote. Our Magento team of developers will assist you in displaying the current user’s name and other details, if necessary.