I'm running Drupal 7 and I want to re-save the user account of the node author after deleting a node of content type picture. I want to do this because I have some code called in hook_user_presave() that counts the number of pictures a user has added and saves it in an integer field in the user.

I looked at hook_node_submit() and hook_node_update(), but when then are invoked, the node is not yet saved, so if I save the user at that point, the int value is one less than it should be (because the added node has not actually been saved yet).

Is there a hook for reacting after a node has been added?

Related question: Hook for reacting after deleting node

3 Answers 3


You can use Hook Post Action module which will provide you hooks like:

  • hook_entity_postsave

  • hook_entity_postinsert

  • hook_entity_postupdate

  • hook_entity_postdelete

  • hook_node_postsave

  • hook_node_postinsert

  • hook_node_postupdate

  • hook_node_postdelete

    These hooks are fired after node is saved to the database. So the process you want to do after node save can be done using these hooks which comes with Hook Post action module.


A site-building option, if you are already using the "Rules" module, is to have a rule that reacts to two events:

  • After saving new content
  • After updating existing content

and then perform the actions you need (for example "Save entity" -> site:current-user). You could also put your custom code in a specific rules action if this is better for your use case.


hook_node_insert - Respond to creation of a new node.

This hook is invoked from node_save() after the database query that will insert the node into the node table is scheduled for execution, after the type-specific hook_insert() is invoked, and after field_attach_insert() is called.

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.