1

I am working Magento 2.x custom module. I have setup ACL rules for this but it is not showing Menu of custom module for custom user roles.

acl.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="technologymindz::base" title="TM Tag Manager" sortOrder="10" >
                    <resource id="technologymindz_googletagmanager::googletagmanager" title="General Settings" sortOrder="10" />
                </resource>
            </resource>
        </resources>
    </acl>
</config>

menu.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Backend/etc/menu.xsd">
    <menu>
        <add id="technologymindz::base" title="TM Tag Manager" module="Technologymindz_GoogleTagManager" sortOrder="10" resource="Technologymindz_GoogleTagManager::sample"/>

        <add id="technologymindz_googletagmanager::googletagmanager" title="General Settings" module="Technologymindz_GoogleTagManager" sortOrder="10" parent="technologymindz::base" action="technologymindz_googletagmanager/items/" resource="Technologymindz_GoogleTagManager::items"/>
    </menu>
</config>

custom module menu listing in resource list and setting is saved. enter image description here

But when login and check for custom user role, it is not showing. enter image description here

Index Controller is using permission

protected function _isAllowed()
{
 return $this->_authorization->isAllowed('technologymindz::base');
}

I have used static content deploy and cache flush

3 Answers 3

2

Change your acl code as below

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Technologymindz_GoogleTagManager::sample" title="TM Tag Manager" sortOrder="10" >
                    <resource id="Technologymindz_GoogleTagManager::items" title="General Settings" sortOrder="10" />
                </resource>
            </resource>
        </resources>
    </acl>
</config>
1
  • Its works for me
    – matinict
    Commented Mar 13, 2020 at 19:16
2

If your resource name is Technologymindz_GoogleTagManager::items then you need to check same in your _isAllowed() method

protected function _isAllowed()
{
    return $this->_authorization->isAllowed('Technologymindz_GoogleTagManager::items');
}

Edit: I also recommend to set id and resource attributes in menu.xml with same values Technologymindz_GoogleTagManager::items

1

The resource attribute on the menu items must match the id attribute from the resource tag in acl.xml

Your resource ids are technologymindz::base and technologymindz_googletagmanager::googletagmanager in acl.xml but your in the menu file you are using technologymindz_googletagmanager::googletagmanager and Technologymindz_GoogleTagManager::items.
Chance the ones in menu.xml to match the ones in acl.xml. Also make sure you match the case sensitivity.

3
  • As per your suggestion i have updated my acl.xml but still not working. ` <resource id="Magento_Backend::admin"> <resource id="technologymindz_googletagmanager::googletagmanager" title="TM Tag Manager" sortOrder="10" > <resource id="Technologymindz_GoogleTagManager::items" title="General Settings" sortOrder="10" /> </resource> `
    – Sohan
    Commented Feb 2, 2017 at 8:03
  • if this is wrong, can you update answer for acl.xml ?
    – Sohan
    Commented Feb 2, 2017 at 8:05
  • if you updated acl.xml you need to create your role again. because the old item values are stored in the database.
    – Marius
    Commented Feb 2, 2017 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.