Same name and namespace in other branches
  1. 4.6.x developer/hooks/node.php \hook_delete()
  2. 4.7.x developer/hooks/node.php \hook_delete()
  3. 5.x developer/hooks/node.php \hook_delete()
  4. 7.x modules/node/node.api.php \hook_delete()

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.

Parameters

&$node: The node being deleted.

Return value

None.

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

1 invocation of hook_delete()
user_delete in modules/user/user.module
Delete a user.

File

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

Code

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