I'm willing to override a value before it get saved in database. The same value is already overriden by commons_trusted_contacts module using hook_node_presave.

So my custom module hook_node_presave get overriden by commons_trusted_contacts_node_presave.
How do I let drupal know that he need to run my custom hook_node_presave after other hook node presave or to not override that single field value.

Below line being overridden :


2 Answers 2


The order of a module's hook invocation is determined by its weight. In Drupal 7 this set in the weight column in the system table.

This can be updated through SQL query by setting your module's weight to the heaviest (last) value.

# Update with the appropriate values for your install
drush sqlq "UPDATE {system} SET weight = [your_preferred_weight] WHERE type = 'module' AND name = '[your_module_name]"'

Or using a module like Modules weight if you need a UI.

See the Drupal.org documentation for more info..

  • Thanks for pointing doc that helped me to come out with the answer bellow by using hook_module_implements_alter. Switching hook order was what I was looking for.
    – funkyD
    Commented Sep 7, 2016 at 9:40

Thanks for pointing drupal.org documentation, It's was helpfull.

I ended up using hook_module_implements_alter which better suited to my situation than changing the module weight.

So I've changed the order in which my hooks are triggered than changing module weight.

/** * Implements hook_module_implements_alter */ function glue_site_module_implements_alter(&$implementations, $hook) { if (($hook == 'node_presave') && isset($implementations['my_module'])) { //dpm($implementations, 'before'); $module = 'my_module'; $group = array($module => $implementations[$module]); unset($implementations[$module]); $implementations = $implementations + $group; } }

Reading Adjusting module weight: what are the risks and things to look out for? also helped me to understand behavior of changing module weight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.