Drupal 6: how to execute php code when a specific node type is created

327 Views Asked by At

I googled it for a long time without sucess. I try in execute some php code when a new node of a specific type is created (or inserted) on my Drupal 6 web site.

It seems I have to do something like that:

function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'insert':
      if ($node->type == 'MY_NODE_TYPE') {
         // execute some code here
      }
  }
}

But I don't understand when is this function called and where do I have to place this code? I'm lost. It would be awesome if someone could give me some hints.

1

There are 1 best solutions below

0
On BEST ANSWER

solution is to create a custom module and to implement this hook wit the name of your newly created module (e.g mymodulename_nodeapi)

Tutorial is here: http://drupal.org/node/206753