Hooks allow modules to alter and extend the behavior of Drupal core, or another module. They are one of several ways that code components in Drupal can communicate with one another. Using hooks, a module developer can change how core or another module works--without changing the existing code. As a Drupal developer, understanding how to implement and invoke hooks is essential.
- Get information, such as a list of links that should be placed in a user toolbar
- Alter something, such as adding or removing a field from the content edit form
- React to a system action, such as when a user cancels their account
Hooks have been a staple of Drupal module development since the beginning. In Drupal, "info" hooks have generally been replaced by the plugin system and many "reactive" hooks have been replaced by events. Check api.drupal.org to see if a hook exists for the latest version of Drupal.
Below are some examples of the types of things you can do with hooks.