Order of executions specific hook by different modules

Public

E.g.: You want to execute hook_form_alter from your module after other modules use this hook.

</> CopyGet raw version
php
  1. /**
  2. * Implements hook_module_implements_alter()
  3. */
  4. function mymodule_module_implements_alter(&$implementations, $hook) {
  5. //Any change here requires Caches to be cleared.
  6. //Order of executions hook_form_alter before called hook_module_implements_alter
  7. $module_name = 'mymodule';
  8. switch ($hook) {
  9. case 'form_alter':
  10. $m1 = $implementations[$module_name];
  11. unset($implementations[$module_name]);
  12.  
  13. $implementations[$module_name] = $m1;
  14. break;
  15. }
  16. //Order of executions after called this hook
  17. //Use 'drush fnh hook_name' to check order
  18. }

Comments

Biswajeet's picture

Awesome