drupaldrupal-node-hook

Modify a node, when another node is being saved?


How to modify another node, when another node is being saved?

i.e can I use a node_save($nid_to_be_saved) in side a hook_node_presave($node_being_saved)?


Solution

  • You can use node_save in hook_node_presave provided the node that is being saved is not saved again. If you want to do that you need to have a flag in the node object $node->presave_saved = TRUE; and do not save again to avoid loops.