Hi all,

What's the best way to trigger an action whenever a node is saved (created/updated)?

Thanks in advance,
Kaspar

Comments

tyswan’s picture

I know nothing about module coding, but I suggest you find the appropriate implementations of:

hook_insert
hook_submit
hook_update

I also found
node_submit

I don't really know what you're trying to do, so check out all these node functions
http://api.drupal.org/api/5/function?page=15

I hope that helps.

Cheers,
--
tys

BLUE MOUNTAINS health & harmony
www.health-harmony.com.au

building an alternative health & spirituality community in the Blue Mountains

danbh’s picture

I think you are looking for hook_nodeapi
The various hooks mentioned by the other poster are for when you are creating your own module. hook_nodeapi is for modules that want to act upon other module's node's update events.

Here is my understanding of drupal's naming conventions:

implement hook_nodeapi(op=update) when you want to act on all node's update events

implement hook_update if you are creating your own node, and you want to add to the standard node update event for your nodes

if there was a node_update, this would be what drupal calls when it is time to update a node. There is no node_update function, because that is part of node_save. node_save is both node_insert and node_update. Of course, you can call this function yourself, if thats what you really need to do, for whatever reason.

ANYWAY, here is a link:
http://api.drupal.org/api/5/function/hook_nodeapi