function hook_hook_info

7.x system.api.php hook_hook_info()
6.x core.php hook_hook_info()

Expose a list of triggers (events) that users can assign actions to.

Note: Implementing this hook doesn't actually make any action functions run. It just lets the trigger module set up an admin page that will let a site administrator assign actions to hooks. To make this work, module needs to:

  • Detect that the event has happened
  • Figure out which actions have been associated with the event. Currently, the best way to do that is to call _trigger_get_hook_aids(), whose inputs are the name of the hook and the name of the operation, as defined in your hook_hook_info() return value)
  • Call the associated action functions using the actions_do() function.

Return value

A nested array:

  • The outermost array key must be the name of your module.

    • The next key represents the name of the hook that triggers the events, but for custom and contributed modules, it actually must be the name of your module.

      • The next key is the name of the operation within the hook. The array values at this level are arrays; currently, the only recognized key in that array is 'runs when', whose array value gives a translated description of the hook.

See also

hook_action_info(), which allows your module to define actions.

Related topics

5 functions implement hook_hook_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

comment_hook_info in drupal-6.x/modules/comment/comment.module
Implementation of hook_hook_info().
node_hook_info in drupal-6.x/modules/node/node.module
Implementation of hook_hook_info().
system_hook_info in drupal-6.x/modules/system/system.module
Implementation of hook_hook_info().
taxonomy_hook_info in drupal-6.x/modules/taxonomy/taxonomy.module
Implementation of hook_hook_info().
user_hook_info in drupal-6.x/modules/user/user.module
Implementation of hook_hook_info().
3 invocations of hook_hook_info()
trigger_assign in drupal-6.x/modules/trigger/trigger.admin.inc
Build the form that allows users to assign actions to hooks.
trigger_forms in drupal-6.x/modules/trigger/trigger.module
Implementation of hook_forms(). We reuse code by using the same assignment form definition for each node-op combination.
trigger_menu in drupal-6.x/modules/trigger/trigger.module
Implementation of hook_menu().

File

documentation-6.x/developer/hooks/core.php, line 328
These are the hooks that are invoked by the Drupal core.

Code

function hook_hook_info() {
  return array(
    'comment' => array(
      'comment' => array(
        'insert' => array(
          'runs when' => t('After saving a new comment'),
        ),
        'update' => array(
          'runs when' => t('After saving an updated comment'),
        ),
        'delete' => array(
          'runs when' => t('After deleting a comment')
        ),
        'view' => array(
          'runs when' => t('When a comment is being viewed by an authenticated user')
        ),
      ),
    ),
  );
}