2

When adding a taxonomy term in Drupal, it redirects back to itself to add another term. Is there a way of overriding this?

I have so far tried:

• Adding ?destination=_ to the page that links to the /add/term/ page
• Tried hook_taxonomy:

function modulename_taxonomy($op, $type, $array = NULL) {
  if ($type == 'term' && ($op == 'insert' || $op == 'update') && $array['parent'][39] == 39) {
    drupal_goto('page.html');
  }
}

If instead of drupal_goto() I put die('Here'); it outputs, but the drupal_goto() does not work?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
jodm
  • 2,607
  • 3
  • 25
  • 40

2 Answers2

5

Implement hook_form_FORM_ID_alter one of the following ways.

  • If you know in advance where you would like to be redirected, change the $form['#redirect'] entry.
  • If you only know after submission where would like to be redirected, add an additional callback to $form['#submit']. That callback receives the $form array and the &$form_state array reference. Set the $form_state['redirect'] entry to he path that you want to redirect to.
Oswald
  • 31,254
  • 3
  • 43
  • 68
  • $form['#redirect'] didn't work so I altered $form['destination'] and now it is redirecting back to where I want it to. Thank you! – jodm May 12 '11 at 07:59
  • You can use $form_state['redirect'] - which is the replacement for $form['#redirect'] – yoavmatchulsky May 12 '11 at 11:01
0

You can use rules module, and i'm sure you can create an action to redirect to an URL.

Brice Favre
  • 1,511
  • 1
  • 15
  • 34