Community Documentation

hook_delete

5 node.php hook_delete(&$node)
6 node.php hook_delete(&$node)
7 node.api.php hook_delete($node)
8 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.

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

▾ 22 functions implement hook_delete()

block_box_delete in modules/block.module
Menu callback; confirm deletion of custom blocks.
book_delete in modules/book.module
Implementation of hook_delete().
comment_delete in modules/comment.module
Menu callback; delete a comment.
contact_admin_delete in modules/contact.module
Category delete page.
fileupload_delete in developer/examples/fileupload.module
Implementation of hook_delete().
file_delete in includes/file.inc
Delete a file.
filter_admin_delete in modules/filter.module
Menu callback; confirm deletion of a format.
forum_delete in modules/forum.module
Implementation of hook_delete().
locale_admin_string_delete in modules/locale.module
Delete a string.
menu_node_form_delete in modules/menu.module
Remove the menu item.
multipage_form_example_delete in developer/examples/multipage_form_example.module
Implementation of hook_delete().
node_delete in modules/node.module
Delete a node.
node_example_delete in developer/examples/node_example.module
Implementation of hook_delete().
node_revision_delete in modules/node.module
Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a revision is deleted.
path_admin_delete in modules/path.module
Post-confirmation; delete an URL alias.
poll_delete in modules/poll.module
Implementation of hook_delete().
profile_field_delete in modules/profile.module
Menu callback; deletes a field from all user profiles.
taxonomy_node_delete in modules/taxonomy.module
Remove associations of a node to its terms.
upload_delete in modules/upload.module
user_admin_access_delete in modules/user.module
Menu callback: delete an access rule
_forum_confirm_delete in modules/forum.module
Returns a confirmation page for deleting a forum taxonomy term.
_locale_string_delete in includes/locale.inc
Delete a language string.

File

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

Code

<?php
function hook_delete(&$node) {
  db_query('DELETE FROM {mytable} WHERE nid = %d', $node->nid);
}
?>
Login or register to post comments