Same name and namespace in other branches
- 10 core/core.api.php \hooks
- 4.7.x includes/module.inc \hooks
- 5.x includes/module.inc \hooks
- 6.x includes/module.inc \hooks
- 7.x includes/module.inc \hooks
- 8.9.x core/core.api.php \hooks
- 9 core/core.api.php \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().
File
- includes/
module.inc, line 103 - API for loading and interacting with Drupal modules.
Functions
Name | Location | Description |
---|---|---|
hook_auth |
developer/ |
Verify authentication of a user. |
hook_info |
developer/ |
Declare authentication scheme information. |
hook_block |
developer/ |
Declare a block or set of blocks. |
hook_comment |
developer/ |
Act on comment modification. |
hook_filter |
developer/ |
Define content filters. |
hook_filter_tips |
developer/ |
Provide tips for using filters. |
hook_cron |
developer/ |
Perform periodic actions. |
hook_db_rewrite_sql |
developer/ |
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. Noteā¦ |
hook_exit |
developer/ |
Perform cleanup tasks. |
hook_footer |
developer/ |
Insert closing HTML. |
hook_help |
developer/ |
Provide online user help. |
hook_init |
developer/ |
Perform setup tasks. |
hook_link |
developer/ |
Define internal Drupal links. |
hook_menu |
developer/ |
Define menu items and page callbacks. |
hook_nodeapi |
developer/ |
Act on nodes defined by other modules. |
hook_node_grants |
developer/ |
Grant access to nodes. |
hook_onload |
developer/ |
Insert a JavaScript onload handler. |
hook_perm |
developer/ |
Define user permissions. |
hook_ping |
developer/ |
Ping another server. |
hook_search |
developer/ |
Define a custom search routine. |
hook_search_item |
developer/ |
Format a search result. |
hook_search_preprocess |
developer/ |
Preprocess text for the search index. |
hook_settings |
developer/ |
Declare administrative settings for a module. |
hook_taxonomy |
developer/ |
Act on taxonomy changes. |
hook_textarea |
developer/ |
React to textarea additions. |
hook_update_index |
developer/ |
Update Drupal's full-text index for this module. |
hook_user |
developer/ |
Act on user account actions. |
hook_xmlrpc |
developer/ |
Register XML-RPC callbacks. |
hook_access |
developer/ |
Define access restrictions. |
hook_delete |
developer/ |
Respond to node deletion. |
hook_form |
developer/ |
Display a node editing form. |
hook_insert |
developer/ |
Respond to node insertion. |
hook_load |
developer/ |
Load node-type-specific information. |
hook_node_name |
developer/ |
Define the human-readable name of a node type. |
hook_node_types |
developer/ |
Define multiple node types. |
hook_update |
developer/ |
Respond to node updating. |
hook_validate |
developer/ |
Verify a node editing form. |
hook_view |
developer/ |
Display a node. |
module_hook |
includes/ |
Determine whether a module implements a hook. |
module_implements |
includes/ |
Determine which modules are implementing a hook. |
module_invoke |
includes/ |
Invoke a hook in a particular module. |
module_invoke_all |
includes/ |
Invoke a hook in all enabled modules that implement it. |