How would you go about restricting a specific directory path to a role?


How do you restrict role access to the directory example1 so that example3 and 4 are restricted automatically?



This depends on what that path is? Drupal has many kinds of paths and default permissions out of the box. If this was a Book hierarchy default permissions exist for books. The same for Taxonomy terms and other types of content. If this was a Views based path, you could configure Access rules in your view.

Without any 3rd party module support I would look at hook_menu if you are defining these paths yourself or hook_menu_alter if they are provided by another module.

Drupal Roles are not a reliable way to deem access to content -- I would alter the access callback for this path to use user_access permission values and create a custom permission such as view my custom site area and give that permission to desired roles. Then I would an access arguments of view my custom site area so the user_access check works on those paths.

The Workbench Access module can do what you're asking if you define the Access rules using the Menu Scheme and not Taxonomies, but this module only works for Nodes last I checked.

Workbench Access provide the hierarchical permissions across "Sections" of your web site. You can use menus, taxonomy, or create your own hierarchical structure for controlling access to a piece of content.

  • Thanks! But I found an easier solution that works for me :-) Linking below – Ithxi Oct 7 '14 at 16:46
  • good job, if you read the module description you'll see they use the exact same formula I described :) – tenken Oct 7 '14 at 17:04

A google search did the job:


The module will enable you to restrict access to certain paths per role. Each role has a page of either ACCESS ONLY or CANNOT ACCESS paths. Easy to set bunch permissions if you play with many roles at once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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