3

Which hooks can I implement in Drupal 7 to add additional processing steps to the node creation process. For example, to run a snippet of PHP code after the node has been successfully saved to the database. I'm assuming hook_form_alter, but I only want to add to the process, not replace the default node save process.

Specifically, I'm looking to make an immediate external API call to SmugMug.com and then trigger an email upon a successful node save.

1 Answer 1

2

In Drupal 6, this was done in hook_nodeapi.

In Drupal 7, this is done in hook_node_update & hook_node_insert

hook_node_update($node) This hook is invoked from node_save() after the node is updated in the node table in the database, after the type-specific hook_update() is invoked, and after field_attach_update() is called.

hook_node_insert($node) This hook is invoked from node_save() after the node is inserted into the node table in the database, after the type-specific hook_insert() is invoked, and after field_attach_insert() is called.

there is also hook_node_presave($node) if you want to do something before its been save

More information on api.drupal.org & link to the D6 to D7 upgrade changes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.