I have created a taxonomy of regions, with the intent of multiple uses:

  1. Users select their region in their profile
  2. Events include a region field.

This should make it rather easy to show users events in their region.

Each of these use cases requires one or two extra terms:

  • Users might be from "outside New Zealand".
  • Events might be "Nationwide", "Worldwide" or indeed "online".

But we don't want events outside NZ submitted, and the latter three terms are not appropriate for users to choose as their location. So I want to disable them from the listed options in each case.

I thought there might be a CSS solution as there are ample distinctive selectors available in the parent elements, but Drupal does not assign any classes to option elements - they only have a value, and the numeric id of the taxonomy term at that.

Is there a way to do this using Rules or Context?

1 Answer 1


Alternative 1

Create two different taxonomy vocabularies:

  • Events
  • Users

since the use cases for each are different.

To create another taxonomy vocabulary easy and fast, you could export your existing terms and then import them into a new vocabulary. This could be done with some taxonomy bulk import/export module, maybe with https://www.drupal.org/project/taxonomy_csv or with https://www.drupal.org/project/taxonomy_manager

Alternative 2

Added to this answer after OP's first comment.

  1. Keep the Events and Users together in one vocabulary, EventsUsers.

  2. Create another vocabulary, EventUserType. Add two terms: Events and Users.

  3. Add a Term reference field with Check boxes/radio buttons to the EventsUsers, save. In the next configuration pages choose vocabulary EventUserType. Also change the Number of values from 1 to Unlimited.

Now all the terms in the main vocabulary can be tagged as Event, User or both.

The filtering could be done using the Views module, but I guess that would be a separate question here on Drupal Answers.

  • I would disagree - It then becomes a challenge to establish a relationship between the two taxonomies (potentially more than two, since we have other uses planned) - to drupal they are just numeric ids. Text matching is expensive and vulnerable to future admins tweaking a term in one taxonomy but not other(s) Oct 15, 2016 at 19:56
  • I understand and agree, too. I will add another alternative to my answer. Oct 16, 2016 at 8:12
  • Thanks Emil. That sounds similar to the other thing I'm setting up - adding the taxonomy as a field to itself to define neighbouring regions. The question that naturally follows from this now that i've set it up, is "how do use this to filter the options in the select element in the user and event create/edit forms?" I'm guessin that will be a hook_form_alter function in template.php, but I've no idea where to start with it. Oct 18, 2016 at 5:02
  • You are welcome! I think that the form manipulation is better asked in a separate question post. That way also other people able to answer it or wondering the same thing will find it. Editing possibilities in a question/answer box is better because there are more options than in the comment section. Oct 18, 2016 at 6:31

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.