Why can't I find the parent term of a tag when a node is being inserted? I'm following another question I asked, How can I get the parent term in a taxonomy with a hierarchy? and I can get the parent term when I am on the view operation, but not when I'm on the insert operation. var_dump() shows the $terms variable, but NULL for $pterms. Here is my code being called in hook_nodeapi('insert').

  foreach ($node-&gt;taxonomy as $term) {
    $terms[] = $term;
  }
  $tid = $terms[0]-&gt;tid;
  $parents = taxonomy_get_parents($tid);
  foreach ($parents as $term) {
    $pterms[] = $term;
  }
Did you try taxonomy_get_parents_all()? 

$parents = taxonomy_get_parents_all($tid);
  foreach ($parents as $term) {
    $pterms[] = $term-&gt;name;
  }