Reading list Switch to dark mode

    How to Get Role and Allowed ACL Resources for Logged in Admin User?

    Updated 11 January 2023

    To get the Role of the Admin Logged in User and the Resources allowed to the logged in user we can have use the following functions. I have declared them in Helper file of my module.

     * Webkul Software.
     * @category  Webkul
     * @package   Webkul_MpMassUpload
     * @author    Webkul
     * @copyright Copyright (c) 2010-2018 Webkul Software Private Limited (
     * @license
    namespace Webkul\AdminRole\Helper;
    class Data extends \Magento\Framework\App\Helper\AbstractHelper
        protected $authSession;
        protected $aclRetriever;
         * @param \Magento\Framework\App\Helper\Context $context
         * @param \Magento\Backend\Model\Auth\Session $authSession
         * @param \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever
        public function __construct(
            \Magento\Framework\App\Helper\Context $context,
            \Magento\Backend\Model\Auth\Session $authSession,
            \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever
        ) {
            $this->authSession = $authSession;
            $this->aclRetriever = $aclRetriever;
         * function to get logged in user role
         * @return string
        public function getRole() {
            return $this->authSession->getUser()->getRole()->getRoleName();
         * function to get the Allowed resources to logged in User
         * @return array
        public function getAllowedResource() {
            $roleId = $this->authSession->getUser()->getRole()->getRoleId();
            return $this->aclRetriever->getAllowedResourcesByRole($roleId);

    Thanks 🙂

    Searching for an experienced
    Magento 2 Company ?
    Read More
    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home