I am creating a module that needs to tag nodes with taxonomy terms when they are created. I have implemented hook_nodeapi() to do this, and am trying to add the term in there like so:
function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'insert':
$node->taxonomy = array(1 => taxonomy_get_term(1));
node_save($node);
break;
}
}
When I call node_save(), the code just goes in to a loop, because node_save calls hook_nodeapi(). When I don't call node_save, nothing is saved. I am durned if I do, durned if I don't. Any ideas on the right way to do thi?