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_delete() and hook_entity_delete() as suggested in this question, but when then are invoked, the node is not yet deleted, so if I save the user at that point, the int value is one more than it should be (because the deleted file has not actually been deleted yet).

Is there a hook for responding to node deletion after it has taken place?

Related question: Hook for reacting after adding node

1 Answer 1


There isn't one. If you look at node_delete_multiple(), which node_delete is a wrapper function for, you can see that the only hook invocations (the above hooks) are triggered before the DB delete statements.

If your Drupal site only allows deleting through the node/$nid/delete form, one alternative to a post-delete hook is appending a submission handler to the node deletion confirmation form:

function MYMODULE_form_node_delete_confirm_alter(&$form, &$form_state, $form_id) {
  $form['#submit'][] = 'MYMODULE_node_delete_confirm_submit';

function MYMODULE_node_delete_confirm_submit($form, &$form_state) {
  //@TODO: Post-node-delete code here

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.