8.5.x module.api.php hook_hook_info()
8.0.x module.api.php hook_hook_info()
8.1.x module.api.php hook_hook_info()
8.2.x module.api.php hook_hook_info()
8.3.x module.api.php hook_hook_info()
8.4.x module.api.php hook_hook_info()
8.6.x module.api.php hook_hook_info()
6.x core.php hook_hook_info()
7.x system.api.php hook_hook_info()

Defines one or more hooks that are exposed by a module.

Normally hooks do not need to be explicitly defined. However, by declaring a hook explicitly, a module may define a "group" for it. Modules that implement a hook may then place their implementation in either $module.module or in $module.$group.inc. If the hook is located in $module.$group.inc, then that file will be automatically loaded when needed. In general, hooks that are rarely invoked and/or are very large should be placed in a separate include file, while hooks that are very short or very frequently called should be left in the main module file so that they are always available.

Return value

An associative array whose keys are hook names and whose values are an associative array containing:

  • group: A string defining the group to which the hook belongs. The module system will determine whether a file with the name $module.$group.inc exists, and automatically load it when required.

See system_hook_info() for all hook groups defined by Drupal core.

See also


Related topics

3 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.

module_hook_info in includes/module.inc
Retrieves a list of hooks that are declared through hook_hook_info().
module_test_hook_info in modules/simpletest/tests/module_test.module
Implements hook_hook_info().
system_hook_info in modules/system/system.module
Implements hook_hook_info().


modules/system/system.api.php, line 37
Hooks provided by Drupal core and the System module.


function hook_hook_info() {
  $hooks['token_info'] = array(
    'group' => 'tokens',
  $hooks['tokens'] = array(
    'group' => 'tokens',
  return $hooks;


kiamlaluno’s picture

Despite the same name, this hook has a purpose that is different from the purpose it had in Drupal 6; for more details see Converting 6.x modules to 7.x.

fgm’s picture

Unlike most other include files making up a module, include files loaded this way do not need to be declared in the module info file.

Dave Reid’s picture

But its probably good practice to do it anyway to avoid any potential problems in the future.

mattyoung’s picture

no need to declare any code file in .info except for files contain interface and class.

rfay’s picture

Due to a late change in Drupal 7, only files that contain a class implementation need to be listed in the files[] declaration in the info file. It doesn't seem to make any sense to do any others.

danielb’s picture

If your implementation doesn't seem to load the file, as is the case for Field API modules, see this bug: http://drupal.org/node/977052

danielb’s picture

Note: This hook is for modules that define hooks, not for modules that implement them. For example you cannot create your own hook_hook_info to put your token hooks into your own group file, like the example shows. That tokens group is defined by the system module, and if you override it with your own hook_hook_info implementation, you will break stuff.

naught101’s picture


sebas5384’s picture

So is just when a module haves their own hooks?

I was looking at this code, and it seems to do exactly what the example says it does, i just wanna be sure about this before using it.


annya’s picture

Yes, this hook is used only by modules that define their own hooks.

roynilanjan’s picture

Rather in more generic we can write as,

 * Implements hook_hook_info().
function $module_hook_info() {
  return array(
    $hook_name => array(
      'group' => $group_name,

Now using the above we can segregate all the hooks in a separate file *$module.$group_name.inc*