I have a taxonomy called Species, and another taxonomy called Protected Areas.

Inside of the Protected Areas I have a multifield widget (Taxonomy reference pointing to Species), where user can select different Species present on the Area.

Users are able to manipulate also the Species taxonomy, when adding a new Species they are able to choose in which Protected Area is this specie present. Then, when users do it, I would like to automatically update the user selected Protected Area taxonomy (for this Species), adding on the multifield widget the recently added Species value.

Even shorter: how to communicate new/changed values between taxonomies.

Some chances to avoid writing my own module? thanks

  • Can you add a drupal version tag please? Commented Feb 12, 2015 at 21:05

1 Answer 1


Unfortunately you are probably stuck writing your own module. You need to implement hook_taxonomy_term_update and hook_taxonomy_term_insert. In each you can check the item being updated and force a change on any associated terms in the other taxonomy.

The one thing to be careful of is an update spiral. Forcing an update on associated terms will then force an update of the original term, because it is now associated. Because the changes in those two hooks are not committed to the db until the whole mess resolves it will lock up unless you put in a variable to keep it from spiraling.

For example:

if ($term->tid == args(2)) _update_related_terms($term);

should check the term being updated against the current page. If they do not match it won't fire. (I haven't tested this snippet, so test thoroughly!)

Then in _update_related_terms

function _update_related_terms($term){
  $associated_terms = $term->associated_term_field; 
  if (isset($associated_terms['und'][0]['tid']) && $associated_terms['und'][0]['tid'] != ''){
    foreach ($associated_terms['und'] as $key => $value){
      if (isset($value['tid']) && $value['tid'] != ''){
        //check the associated term here.  You could load it, or check the db, or all sort of things

I know I am using und in this example, but it is off the cuff. Again, not tested

Please note: this example is for d7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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