Thursday, March 31

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.

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


$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.

2 comments:

  1. $user = Mage::getModel('admin/user')->getCollection()->getData();

    from the above code you can get the collection data of admin. To get email see the code below
    foreach($user as $userData=>$val){
    $email=$val['email'];
    }

    ReplyDelete
    Replies
    1. oh thanks fine. this is also easy to get admin data

      Delete