function hook_node_delete

Respond to node deletion.

This hook is invoked from node_delete_multiple() after the type-specific hook_delete() has been invoked, but before hook_entity_delete and field_attach_delete() are called, and before the node is removed from the node table in the database.

Parameters

$node: The node that is being deleted.

Related topics

14 functions implement hook_node_delete()

Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.

book_node_delete in modules/book/book.module
Implements hook_node_delete().
comment_node_delete in modules/comment/comment.module
Implements hook_node_delete().
EntityCrudHookTestHooks::nodeDelete in core/modules/system/tests/modules/entity_crud_hook_test/src/Hook/EntityCrudHookTestHooks.php
Implements hook_ENTITY_TYPE_delete() for node entities.
entity_crud_hook_test_node_delete in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_node_delete().
forum_node_delete in modules/forum/forum.module
Implements hook_node_delete().

... See full list

1 invocation of hook_node_delete()
node_delete_multiple in modules/node/node.module
Deletes multiple nodes.

File

modules/node/node.api.php, line 475

Code

function hook_node_delete($node) {
    db_delete('mytable')->condition('nid', $node->nid)
        ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.