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.
node_save($node);
right after$node->title = 'test';
. And flush cache. But maybe better rely onhook_node_insert
. Not sure.custom_site_
and notcustom_
. I would advise devising a better naming strategy.