function hook_delete
hook_delete($node)
Respond to node deletion.
This is a node-type-specific hook, which is invoked only for the node type being affected. See Node API hooks for more information.
Use hook_node_delete() to respond to node deletion of all node types.
This hook is invoked from node_delete_multiple() before hook_node_delete() is invoked and before field_attach_delete() is called.
Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the delete operation is entirely completed and node_delete_multiple() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check node_delete_multiple() and db_transaction() for more info.
Parameters
$node: The node that is being deleted.
Related topics
File
- modules/node/node.api.php, line 1063
- Hooks provided by the Node module.
Code
function hook_delete($node) { db_delete('mytable') ->condition('nid', $node->nid) ->execute(); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_delete/7.x