Hooks

  1. 7.x drupal/includes/module.inc hooks
  2. 5.x drupal/includes/module.inc hooks
  3. 6.x drupal/includes/module.inc hooks
  4. 8.x drupal/core/includes/module.inc hooks

Allow modules to interact with the Drupal core.

Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.

To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and call that hook in all enabled modules that implement it.

The available hooks to implement are explained here in the Hooks section of the developer documentation. The string "hook" is used as a placeholder for the module name is the hook definitions. For example, if the module file is called example.module, then hook_help() as implemented by that module would be defined as example_help().

Functions

Namesort descending Location Description
custom_url_rewrite documentation/developer/hooks/core.php custom_url_rewrite is not a hook. It is a function you can add to settings.php to manage aliases with some code.
hook_access documentation/developer/hooks/node.php Define access restrictions.
hook_auth documentation/developer/hooks/authentication.php Verify authentication of a user.
hook_block documentation/developer/hooks/core.php Declare a block or set of blocks.
hook_comment documentation/developer/hooks/core.php Act on comments.
hook_cron documentation/developer/hooks/core.php Perform periodic actions.
hook_db_rewrite_sql documentation/developer/hooks/core.php Add JOIN and WHERE statements to queries and decide whether the primary_field shall be made DISTINCT. For node objects, primary field is always called nid. For taxonomy terms, it is tid and for vocabularies it is vid. For comments, it is cid. Primary…
hook_delete documentation/developer/hooks/node.php Respond to node deletion.
hook_disable documentation/developer/hooks/install.php Perform necessary actions before module is disabled.
hook_elements documentation/developer/hooks/core.php Allows modules to declare their own form element types and specify their default values.
hook_enable documentation/developer/hooks/install.php Perform necessary actions after module is enabled.
hook_exit documentation/developer/hooks/core.php Perform cleanup tasks.
hook_file_download documentation/developer/hooks/core.php Allow file downloads.
hook_filter documentation/developer/hooks/core.php Define content filters.
hook_filter_tips documentation/developer/hooks/core.php Provide tips for using filters.
hook_footer documentation/developer/hooks/core.php Insert closing HTML.
hook_form documentation/developer/hooks/node.php Display a node editing form.
hook_forms documentation/developer/hooks/core.php Map form_ids to builder functions.
hook_form_alter documentation/developer/hooks/core.php Perform alterations before a form is rendered.
hook_help documentation/developer/hooks/core.php Provide online user help.
hook_info documentation/developer/hooks/authentication.php Declare authentication scheme information.
hook_init documentation/developer/hooks/core.php Perform setup tasks.
hook_insert documentation/developer/hooks/node.php Respond to node insertion.
hook_install documentation/developer/hooks/install.php Install the current version of the database schema.
hook_link documentation/developer/hooks/core.php Define internal Drupal links.
hook_link_alter documentation/developer/hooks/core.php Perform alterations before links on a node are rendered. One popular use of this hook is to modify/remove links from other modules. If you want to add a link to the links section of a node, use hook_link instead.
hook_load documentation/developer/hooks/node.php Load node-type-specific information.
hook_mail_alter documentation/developer/hooks/core.php Alter any aspect of the emails sent by Drupal. You can use this hook to add a common site footer to all outgoing emails; add extra header fields and/or modify the mails sent out in any way. HTML-izing the outgoing mails is one possibility. See also…
hook_menu documentation/developer/hooks/core.php Define menu items and page callbacks.
hook_nodeapi documentation/developer/hooks/core.php Act on nodes defined by other modules.
hook_node_access_records documentation/developer/hooks/core.php Set permissions for a node to be written to the database.
hook_node_grants documentation/developer/hooks/core.php Inform the node access system what permissions the user has.
hook_node_info documentation/developer/hooks/node.php Define module-provided node types.
hook_node_operations documentation/developer/hooks/core.php Add mass node operations.
hook_node_type documentation/developer/hooks/node.php Act on node type changes.
hook_perm documentation/developer/hooks/core.php Define user permissions.
hook_ping documentation/developer/hooks/core.php Ping another server.
hook_prepare documentation/developer/hooks/node.php This is a hook used by node modules. It is called after load but before the node is shown on the add/edit form.
hook_profile_alter documentation/developer/hooks/core.php Perform alterations profile items before they are rendered. You may omit/add/re-sort/re-categorize, etc.
hook_requirements documentation/developer/hooks/install.php Check installation requirements that need to be satisfied.
hook_search documentation/developer/hooks/core.php Define a custom search routine.
hook_search_preprocess documentation/developer/hooks/core.php Preprocess text for the search index.
hook_submit documentation/developer/hooks/node.php This is a hook used by node modules. It is called after validation has succeeded and before insert/update. It is used to for actions which must happen only if the node is to be saved. Usually, $node is changed in some way and then the actual saving of…
hook_taxonomy documentation/developer/hooks/core.php Act on taxonomy changes.
hook_uninstall documentation/developer/hooks/install.php Remove any tables or variables that the module sets.
hook_update documentation/developer/hooks/node.php Respond to node updating.
hook_update_index documentation/developer/hooks/core.php Update Drupal's full-text index for this module.
hook_update_N documentation/developer/hooks/install.php Perform a single update.
hook_user documentation/developer/hooks/core.php Act on user account actions.
hook_user_operations documentation/developer/hooks/core.php Add mass user operations.
hook_validate documentation/developer/hooks/node.php Verify a node editing form.
hook_view documentation/developer/hooks/node.php Display a node.
hook_xmlrpc documentation/developer/hooks/core.php Register XML-RPC callbacks.
module_hook drupal/includes/module.inc Determine whether a module implements a hook.
module_implements drupal/includes/module.inc Determine which modules are implementing a hook.
module_invoke drupal/includes/module.inc Invoke a hook in a particular module.
module_invoke_all drupal/includes/module.inc Invoke a hook in all enabled modules that implement it.

File

drupal/includes/module.inc, line 289
API for loading and interacting with Drupal modules.