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

▾ 24 functions implement hook_delete()

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.
file_delete in includes/file.inc
Delete a file.
filter_admin_delete in modules/filter/filter.admin.inc
Menu callback; confirm deletion of a format.
forum_confirm_delete in modules/forum/forum.admin.inc
Returns a confirmation page for deleting a forum taxonomy term.
hook_actions_delete in developer/hooks/core.php
Execute code after an action is deleted.
Language deletion functionality in includes/locale.inc
menu_link_delete in includes/menu.inc
Delete one or several menu links.
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.
path_admin_delete in modules/path/path.module
Post-confirmation; delete an URL alias.
poll_delete in modules/poll/poll.module
Implementation of hook_delete().
profile_field_delete in modules/profile/profile.admin.inc
Menu callback; deletes a field from all user profiles.
taxonomy_node_delete in modules/taxonomy/taxonomy.module
Remove associations of a node to its terms.
taxonomy_term_confirm_delete in modules/taxonomy/taxonomy.admin.inc
Form builder for the term delete form.
taxonomy_vocabulary_confirm_delete in modules/taxonomy/taxonomy.admin.inc
Form builder for the vocabulary delete confirmation form.
Translation delete interface. in includes/locale.inc
trigger_actions_delete in modules/trigger/trigger.module
Implementation of hook_actions_delete().
upload_delete in modules/upload/upload.module
user_confirm_delete in modules/user/user.pages.inc
Form builder; confirm form for user deletion.
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

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