Home » Magento9 March 2011

Magento: How to get admin user id, name, username, email, etc?

Here is a quick code to get the admin user’s data (id, name, username, email, password, etc).

By admin user, I mean the users that login through the admin panel and those who have access to the admin panel of Magento. The users can be administrator, or with some specific roles.

$userArray = Mage::getSingleton('admin/session')->getData();

$user = Mage::getSingleton('admin/session');
$userId = $user->getUser()->getUserId();
$userEmail = $user->getUser()->getEmail();
$userFirstname = $user->getUser()->getFirstname();
$userLastname = $user->getUser()->getLastname();
$userUsername = $user->getUser()->getUsername();
$userPassword = $user->getUser()->getPassword();

Hope this helps. Thanks.

From Mukesh Chapagain's Blog, post Magento: How to get admin user id, name, username, email, etc?

php magento mukesh chapagain

Get New Post by Email

Find me on

Facebook Twitter Google+ LinkedIn RSS Feed
  • Nmohanswe

    hi when i used this code in productcontroller.php it says the following error. please let me know the solution

    Fatal error: Call to a member function getUser() on a non-object in /opt/lampp/htdocs/enlarge/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php on line 175

  • http://blog.chapagain.com.np/ Mukesh

    Actually, getData was the problem.

    The following way will not give the error:-

    $user = Mage::getSingleton(‘admin/session’);$userId = $user->getUser()->getUserId();
    I have corrected/edited the post as well.

  • Padidiver56

    I don’t understand. How do I use this?

  • Sshegde123

    Hi Mukesh,

              I am a fan of you. Your all magento solutions are very easy to understand. Thank you.

  • JayDave90

    Thanks.  Helped

  • curcin2

    Where & how does this work now?

    I really want to try it out but lack the know how to use it though.

  • mariya

    hi ,
    its very siple code .its worked for me….thank you….

  • http://www.facebook.com/praful.rajput Praful Rajput

    is was very helpful for me…thanks!!!

  • http://www.facebook.com/people/Nitin-Bansal/1354704949 Nitin Bansal

    Really helpful…thnx sooo much

  • Nathan

    Thanks For your sharing.. Its working Great……

  • Rao

    thanks for this post. question: how can i get store id by admin user id?

  • champjr

    Thank you, it helps me a lot !