Exploring Drupal hooks
You can customize the behavior of CiviCRM by developing a module that takes advantage of the hook system.
CiviCRM is written in a scripting language called PHP, and you use PHP to create all the functions that make CiviCRM work. Some of these functions are exposed to your CMS—in this case, Drupal. For example, there is a function called civicrm_postProcess
that runs every time a form is submitted.
You can copy this function and customize it. Each time civicrm_postProcess
runs, CiviCRM checks whether there is a customized version of the function, and if there is, it runs that instead. Not all CiviCRM functions are exposed in this way. If they are, they are called
hooks.
This recipe shows you how to explore these hooks in Drupal using the civicrm_developer
module.
How to do it…
Hooks allow the CMS to extend the functionality of CiviCRM without having to alter any core CiviCRM files. Here, we will add a module that allows us to see which hooks are available...