I am building a custom admin extension, I need to find a user's role having it's ID, any way to do this, I've been trying to find where does magento store the info on what users are what role with no luck so far. Any help would be very appreciated.
Assuming you're talking about the users who log into the admin console, this should get you what you want.
//By ID
$id = 2;
$role_data = Mage::getModel('admin/user')->load($id)->getRole()->getData();
var_dump($role_data);
//By Username
$username = 'admin';
$role_data = Mage::getModel('admin/user')->getCollection()->addFieldToFilter('username',$username)->getFirstItem()->getRole()->getData();
var_dump($role_data);
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'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With