Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - How to query admin's role name?

I am trying to get the name of the role of the currently logged in admin. I can get the admin user, but I can't figure out how to query their role name. The Magento docs are weak =/

$usr = Mage::getSingleton('admin/session')->getUser();

Ideas anyone?

like image 520
mwalsher Avatar asked Jan 07 '10 23:01

mwalsher


2 Answers

Spoke too soon... I got the role name as follows:

$roleId = implode('', Mage::getSingleton('admin/session')->getUser()->getRoles());
$roleName = Mage::getModel('admin/roles')->load($roleId)->getRoleName();
like image 52
mwalsher Avatar answered Sep 21 '22 01:09

mwalsher


Using this code you will get the role of current user

$admin_user_session = Mage::getSingleton('admin/session');
$adminuserId = $admin_user_session->getUser()->getUserId();
$role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole()->getData();
$role_name = $role_data['role_name'];
like image 23
user2753425 Avatar answered Sep 19 '22 01:09

user2753425