Home » Magento16 February 2010

Magento: Access denied in admin of custom module

I was building a custom module in Magento. I had created a system.xml file for storing configuration data from admin. From the below system.xml file, you can see that I have created a section named ‘My Module Name‘ which can be accessed from Admin –> System –> Configuration.

In the file below, I have just displayed the section and groups name. I have omitted others fields with dots, as they are not necessary here.

<?xml version="1.0" encoding="UTF-8"?>
<config>
   <sections>         
		<my_section_name translate="label" module="mymodulename">
			<label>My Module Name</label>
			...
			..
			.
			<groups>
				<my_group_name translate="label" module="mymodulename">
					<label>My Group Name</label>
					...
					..
					.
					<fields>
						...
						..
						.
					</fields>
				</my_group_name>
			</groups>
			<groups>
				<second_group_name translate="label" module="mymodulename">
					<label>Second Group Name</label>
					...
					..
					.
					<fields>
						...
						..
						.
					</fields>
				</second_group_name>
			</groups>
		</my_section_name>			
    </sections>
</config>

Now, when I try to access the ‘My Module Name‘ tab present in Admin –> System –> Configuration, I get the ‘Access Denied‘ Error.

I searched the internet about this problem. In the magentocommerce forum, people suggested to log out and relogin. But it didn’t slove my problem.

Inchoo suggested to edit administrator roles. But, it didn’t solve either.

Then I tried Activecodeonline’s solution. It suggested me to set some nodes in config.xml file of my module. I also think that it’s XML related problem. But this solution didn’t solve my problem. The ‘Access Denied‘ error still exists.

Finally, Activecodeonline was very useful to me ;). Actually, I had 2 groups in my system.xml file (see above xml). Hence, I need to add both group names as children in config.xml file of my module.

Regarding my system.xml file, the following XML is to be added in the config.xml file.

<system>
	<children>
		<config>
			<children>
				<my_group_name>
					<title>My Group Name</title>
				</my_group_name>
				<second_group_name>
					<title>My Second Group Name</title>
				</second_group_name>
			</children>
		</config>
	</children>
</system>

Here is my config.xml file which solved my problem. Unnecessary parts for here are removed with dots (…) :)

<?xml version="1.0"?>
<config>
    <modules>
       ...
	   ..
	   .
    </modules>
    <frontend>
        ...
		..
		.
    </frontend>
    <admin>
        ...
		..
		.
    </admin>
    <adminhtml>
		<menu>
			...
			..
			.
		</menu>
		<acl>
			<resources>
				<all>
					<title>Allow Everything</title>
				</all>
				<admin>
					<children>
						<MyCompany_MyModule>
							<title>My Module</title>
							<sort_order>10</sort_order>
						</MyCompany_MyModule>
						<system>
							<children>
								<config>
									<children>
										<my_group_name>
											<title>My Group Name</title>
										</my_group_name>
										<second_group_name>
											<title>My Second Group Name</title>
										</second_group_name>
									</children>
								</config>
							</children>
						</system>
					</children>
				</admin>
			</resources>
		</acl>
		<layout>
			...
			..
			.
		</layout>
    </adminhtml>   
    <global>
        ...
		..
		.
    </global>
</config>

Hope this helps and thanks for reading.

From Mukesh Chapagain's Blog, post Magento: Access denied in admin of custom module

php magento mukesh chapagain

Get New Post by Email

Find me on

Facebook Twitter Google+ LinkedIn RSS Feed
  • Kamil

    Thanks for the tip!
    Link to Activecodeonline is broken (actually it’s http://ajzele.net/access-denied-magento-module-error)

  • Thanh tung

    actual exactly error and fix. thank you.

  • Tore

    I create a new tab and a new set for a payment module, but if I set this module as active it is not showing in checkout payments methods. When I put this module in payment section it is showing in the checkout payments methods, What to add to view this payment module when I put it in a custom section? Thanks in advance and sorry for my bed english.

  • http://twitter.com/SkyeADG Joel

    Is this possibly related to the issue where the entire Configuration Page (except the Current Configuration Scope field and Manage Stores link) displays blank and selecting Default Store View results in an Access Denied message?  My URL turns into this when I select Default Store view:

    https://website/magento/index.php/admin/admin/system_config/denied/section/feed/website/base/store/default/key/f66e3311e4e7f295651b3d6c9fb0458e/

    Finding anything useful on this has been a major PITA.  I would greatly appreciate any insight you may have into this matter.

  • Neha C

    Hi,

    I still got same message.