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

Respond to node deletion.

This is a hook used by node modules. It is called to allow the module to take action when a node is being deleted from the database by, for example, deleting information from related tables.


&$node: The node being deleted.

Return value


To take action when nodes of any type are deleted (not just nodes of the type defined by this module), use hook_nodeapi() instead.

For a detailed usage example, see node_example.module.

Related topics

21 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
Delete a single action from the database.
block_box_delete in modules/block/block.admin.inc
Menu callback; confirm deletion of custom blocks.
comment_confirm_delete in modules/comment/comment.admin.inc
Form builder; Builds the confirmation form for deleting a single comment.
comment_delete in modules/comment/comment.admin.inc
Menu callback; delete a comment.
contact_admin_delete in modules/contact/contact.admin.inc
Category delete page.

... See full list

5 invocations of hook_delete()
node_delete in modules/node/node.module
Delete a node.
node_type_delete in modules/node/node.module
Deletes a node type from the database.
taxonomy_del_term in modules/taxonomy/taxonomy.module
Delete a term.
taxonomy_del_vocabulary in modules/taxonomy/taxonomy.module
Delete a vocabulary.
user_delete in modules/user/user.module
Delete a user.


developer/hooks/node.php, line 189
These hooks are defined by node modules, modules that define a new kind of node.


function hook_delete(&$node) {
  db_query('DELETE FROM {mytable} WHERE nid = %d', $node->nid);