Drupal Hook for taxonomy weight change

106 Views Asked by At

Is there any hook or way to execute a code when we change the taxonomy terms weight. E.g When we change create parent/child relationship between the terms. function hook_taxonomy_term_update Doesn't seem to work for that.

1

There are 1 best solutions below

0
batMask On

This will do the job.

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
    switch ($form_id) {
        case 'taxonomy_overview_terms':

          if($form['#vocabulary']->machine_name == 'your_vocabulary_name'){
            //adding a custom callback for after re-ordering
            $form['#submit'][] = 'mymodule_custom_callback';
          }

        break;
    }
}

function mymodule_custom_callback(){
    //custom logic
}