4.6.x node.php hook_delete(&$node)
4.7.x node.php hook_delete(&$node)
5.x node.php hook_delete(&$node)
6.x node.php hook_delete(&$node)
7.x node.api.php hook_delete($node)

Respond to node deletion.

This is a node-type-specific hook, which is invoked only for the node type being affected. See Node API hooks for more information.

Use hook_node_delete() to respond to node deletion of all node types.

This hook is invoked from node_delete_multiple() before hook_node_delete() is invoked and before field_attach_delete() is called.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the delete operation is entirely completed and node_delete_multiple() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check node_delete_multiple() and db_transaction() for more info.


$node: The node that is being deleted.

Related topics

82 functions implement hook_delete()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

actions_delete in includes/actions.inc
Deletes a single action from the database.
block_custom_block_delete in modules/block/block.admin.inc
Form constructor for the custom block deletion form.
block_menu_delete in modules/block/block.module
Implements hook_menu_delete().
block_user_role_delete in modules/block/block.module
Implements hook_user_role_delete().
book_node_delete in modules/book/book.module
Implements hook_node_delete().

... See full list

2 invocations of hook_delete()
field_attach_delete in modules/field/field.attach.inc
Delete field data for an existing entity. This deletes all revisions of field data for the entity.
field_purge_data in modules/field/field.crud.inc
Purges the field data for a single field on a single pseudo-entity.


modules/node/node.api.php, line 1063
Hooks provided by the Node module.


function hook_delete($node) {
    ->condition('nid', $node->nid)


mayur.pimple’s picture

how to delete all content

sinasalek’s picture

Currently Drupal core does not offer any hook to do actions after a node/entity is inserted/updated/deleted in Database. So for example you can not send an email mentioning the node after the node is inserted because Drupal uses SQL transactions and the node is not yet fully written to database when hook node presave is called so if for any reason the transaction is rolled back, users will receive a false mail.

So Hook Post Action module introduces several new Drupal hooks to overcome this limitation:
- hook_entity_postsave
- hook_entity_postinsert
- hook_entity_postupdate
- hook_entity_postdelete
- hook_node_postsave
- hook_node_postinsert
- hook_node_postupdate
- hook_node_postdelete


quardz’s picture

thanks sinasalek , i started using this module, i used more than 10 sites for development, Thanks for a great module, you saved my time.