Magento : how to get current user ?

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

Frontend :

if(Mage::getSingleton('customer/session')->isLoggedIn())
{
     Mage::getSingleton('customer/session')->getCustomer();
}
//or
Mage::helper('customer')->getCustomerName();

Backend :

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

Leave a Reply