How can I get collection of all roles (System->Permission->Roles) and users which has this role?
Thanks.
REST Roles grid is shown with two user types by default: Customer Guest Let's say, for example, that we are going to use the Magento REST service for updating Products and Customers, and we need Admin permissions for that. We don't want to enable neither Guest or Customer user to be able to do that.
To get all the Roles
$roles = Mage::getModel('admin/roles')->getCollection();
foreach($roles as $role):
echo '<br/>Role : '.$role->getId()." | ".$role->getRoleName();
endforeach;
To get the Role users
$roles_users = Mage::getResourceModel('admin/roles_user_collection');
foreach($roles_users as $roleuser):
$user = Mage::getModel('admin/user')->load($roleuser->getUserId());
echo '<br/>User : '.$user->getUsername()." | ".$user->getFirstname();
endforeach;
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