hook_node_presave

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 hook_node_presave($node)

Act on a node being inserted or updated.

This hook is invoked from node_save() before the node is saved to the database.

Parameters

$node The node that is being inserted or updated.

Related topics

Code

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

<?php
function hook_node_presave($node) {
  if ($node->nid && $node->moderate) {
    // Reset votes when node is updated:
    $node->score = 0;
    $node->users = '';
    $node->votes = 0;
  }
}
?>