Magento : how to get current user ?

Need to get the current user in magneto ?
Here how to.

Frontend :

1
2
3
4
5
6
if(Mage::getSingleton('customer/session')->isLoggedIn())
{
     Mage::getSingleton('customer/session')->getCustomer();
}
//or
Mage::helper('customer')->getCustomerName();

Backend :

1
2
3
$user = Mage::getSingleton('admin/session')->getUser();
//bonus : roles
$uer->getRoles();

Leave a Reply