I have a module that creates several admin/settings/modname pages.
I created a new role.
I want this role to only be able to access one specific page, say admin/setting/modname/custom1
How would I go about assigning access right only to that page to this role?
Would this be done under my hook_menu under access arguments?
Right now, the role gets Access Denied on all pages.
You can implement
hook_permto provide a set of custom permissions for your module:And then in your menu item in
hook_menuuse theaccess argumentsas you suggest:Once you’ve installed your module/cleared Drupal’s caches go to the permissions admin page and grant your new permission to the required role and users with that role will (in theory) be able to access it.
I say “in theory” because if your path resides under
admin/then the role will also need theaccess administration pagespermission in order to view the page, which would introduce potential security issues. Your best bet would be to change the path to somewhere other thanadmin/to avoid having to deal with this.