function hook_node_presave

7.x 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.


$node: The node that is being inserted or updated.

Related topics

5 functions implement hook_node_presave()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

book_node_presave in drupal/modules/book/book.module
Implements hook_node_presave().
entity_crud_hook_test_node_presave in drupal/modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_node_presave().
forum_node_presave in drupal/modules/forum/forum.module
Implements hook_node_presave().
node_test_node_presave in drupal/modules/node/tests/node_test.module
Implements hook_node_presave().
trigger_node_presave in drupal/modules/trigger/trigger.module
Implements hook_node_presave().
3 invocations of hook_node_presave()
field_attach_presave in drupal/modules/field/
Perform necessary operations just before fields data get saved.
node_save in drupal/modules/node/node.module
Saves changes to a node or adds a new node.
user_save in drupal/modules/user/user.module
Save changes to a user account or add a new user.


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


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