Skip navigation
Help

hook_node_presave

7 node.api.php 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

5 functions implement hook_node_presave()

1 invocation of hook_node_presave()

File

drupal/modules/node/node.api.php, line 672
Hooks provided by the Node module.

Code

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