4

I gave to users the Administer vocabularies and terms permission to let them access the page on admin/structure/taxonomy, but I want to restrict the access to that page to certain vocabularies.

The only issue that remains is the Add vocabulary permission that comes with Administer vocabularies and terms.

How can I restrict users from creating/editing some vocabularies and still giving the permission to maintain taxonomy terms in other vocabularies?

2 Answers 2

1

"Creating a new vocabulary" is what you do using the URL admin/structure/taxonomy/add, while "Editing existing vocabularies" (say with machine name demotags) is done using the URL admin/structure/taxonomy/demotags/edit.

A possible solution to "restrict" access to these URLs (which seems to be the missing piece you are looking for) is to use the Rules module for this. To do so, have a look at my answer to the question "How to make the permissions of a module more granular?". It includes a rule (in rules export format), which you should be able to use if you apply these minor tunings to it:

  • Check the Rules Condition about which roles this validation should be applied for (if any, if not remove that condition).
  • Adapt the Rules Condition with the URLs containing visitors (to match the taxonomy related URLs like in my first paragraph).
  • You probably don't need the Rules Condition with the "regex" in it (you only have a few URLs to be validated). In that case, you don't need the "OR" part either.
  • Review the Rules Action (the message you want to show, and the redirect you want to force).
0
0
  1. Create a new permission called for example 'Add new vocabulary'
 /**
  * Implements hook_permission().
  */
   function YOUR-CUSTOM-MODULE-NAME_permission() {
      $permissions = array(
        'add new vocabulary' => array(
          'title' => t('Add new vocabulary'),
        ),
      );
      return $permissions;
    }
  1. Alter menu admin/struture/taxonomy/add 'access arguments'
 
  /**
  * Implements hook_menu_alter().
  */
   function YOUR-CUSTOM-MODULE-NAME_menu_alter(&$items) {
   $items['admin/structure/taxonomy/add']['access arguments'] = 
    array('add new vocabulary');
   }
  1. From admin/people/permissions you will find your new permission 'Add new vocabulary' under your YOUR-CUSTOM-MODULE-NAME, and give it only to your desired roles.

Your Answer

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