Access denied for admin users in the custom module magento

Access denied for admin users in the custom module magento

July 31, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Access denied for admin users in the custom module magento

Access Denied for Admin Users in Custom Magento Module

As a senior developer at Laravel Company, I frequently encounter issues like the one described above when working on custom modules for Magento. In this post, let’s dive into a comprehensive solution to resolve the “Access denied” error you’re facing with admin users.

The Problem: Incorrect ACL Permissions

The root cause of your issue lies in the Access Control List (ACL) permissions defined in your config.xml file. When you create a new module, it’s crucial to configure the ACL correctly for both admin and frontend users.

In your case, you’ve defined an index action under the <virtualretailer> router but have not granted access to this resource in the ACL section. This oversight is preventing your custom user from accessing the module even though the appropriate role has been assigned.

The Solution: Correcting ACL Permissions

To resolve this issue, you need to update both the config.xml and adminhtml.xml files for your custom module.

Step 1: Update config.xml

Open your config.xml file and find the <acl> section within the <global> tag. You should have a structure similar to this:

<acl>
    <resources>
        <admin>
            <children>
                <!-- Your existing ACL permissions here -->
            </children>
        </admin>
    </resources>
</acl>

Step 2: Grant Access to Custom Actions

You need to grant access to the custom actions you’ve defined in your router. In your case, add the following children under the <admin> tag:

<resources>
    <admin>
        <children>
            <!-- Define new ACL permissions for your custom module -->
            <virtualretailer translate="title">
                <title>Virtual Retailer</title>
                <sort_order>-100</sort_order>
                <children>
                    <!-- Grant access to index action -->
                    <index translate="title">
                        <title>Home Action</title>
                        <sort_order>1</sort_order>
                    </index>
                </children>
            </virtualretailer>
        </children>
    </admin>
</resources>

Step 3: Update adminhtml.xml

Next, open your adminhtml.xml file and ensure the <acl> section matches the updated structure in your config.xml.

<acl>
    <resources>
        <admin>
            <children>
                <!-- Your existing ACL permissions here -->
                <virtualretailer translate="title">
                    <title>Virtual Retailer</title>
                    <sort_order>-100</sort_order>
                    <children>
                        <!-- Grant access to index action -->
                        <index translate="title">
                            <title>Home Action</title>
                            <sort_order>1</sort_order>
                        </index>
                    </children>
                </virtualretailer>
            </children>
        </admin>
    </resources>
</acl>

Best Practices for Magento ACL Permissions

As a best practice, always ensure that the <acl> sections in both config.xml and adminhtml.xml are accurately synchronized. This helps maintain a clean and functional structure for your custom module.

Another important consideration is to define clear and descriptive titles for each action within the <children> section of the <admin> tag. This enhances readability and makes future maintenance easier.

Conclusion: Resolving Access Denied Errors

By carefully updating the ACL permissions in both config.xml and adminhtml.xml, you should now be able to resolve the “Access denied” error for your custom module.

Remember, properly configuring access controls is a critical aspect of building secure and functional Magento extensions. Always ensure that each action within your router has corresponding ACL permissions defined.

If you find yourself facing complex security challenges or need further guidance on Magento development best practices, don’t hesitate to reach out to the experts at Laravel Company. We’re committed to helping you build robust and reliable e-commerce solutions.

Indexing Security Extensions Admin

Our network