Module Development

Define and Invoke a New Hook for Drupal 8, 9, and 10

As a module developer you should define and invoke new hooks in your module in order to allow other developers -- or even future you -- to extend your module's functionality without hacking your module's code. This requires:

  • Creating a new, unique, name for your hook
  • Providing documentation for your hook
  • Invoking the hook at critical points in your code

By the end of this tutorial you should have a better idea of when to define a new hook and know how to invoke a hook from your code.

Drupal Module Development