Skip to main content
3 of 5
added 325 characters in body
sndr
  • 1
  • 2

hook_node_update not working

I placed the following function in my custom module.

function MYMODULE_node_update($node) {
  if ($node->type === 'page') {
    $node->title = 'test';
  }
}

When editing and saving a node of content type page nothing happens. What can be the issue?


Problem solved. It seemed to be caused by the following:

my custom module wasn't ending with ?> and above all my module name was custom_site.module and my hooks started with custom. This didn't give problems before with my other hooks so I never noticed. (This helped: https://drupal.stackexchange.com/a/111272/85560)

My module name now is custom.module and now custom_node_presave() works.

sndr
  • 1
  • 2