Same name and namespace in other branches
- 10 core/core.api.php \hooks
- 4.6.x includes/module.inc \hooks
- 4.7.x includes/module.inc \hooks
- 5.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 calls 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 in 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 379 - API for loading and interacting with Drupal modules.
Functions
Name | Location | Description |
---|---|---|
page_cache_fastpath |
developer/ |
Outputs a cached page. |
module_invoke_all |
includes/ |
Invoke a hook in all enabled modules that implement it. |
module_invoke |
includes/ |
Invoke a hook in a particular module. |
module_implements |
includes/ |
Determine which modules are implementing a hook. |
module_hook |
includes/ |
Determine whether a module implements a hook. |
hook_xmlrpc |
developer/ |
Register XML-RPC callbacks. |
hook_watchdog |
developer/ |
Log an event message |
hook_view |
developer/ |
Display a node. |
hook_validate |
developer/ |
Verify a node editing form. |
hook_user_operations |
developer/ |
Add mass user operations. |
hook_user |
developer/ |
Act on user account actions. |
hook_update_status_alter |
developer/ |
Alter the information about available updates for projects. |
hook_update_projects_alter |
developer/ |
Alter the list of projects before fetching data and comparing versions. |
hook_update_N |
developer/ |
Perform a single update. |
hook_update_last_removed |
developer/ |
Return a number which is no longer available as hook_update_N(). |
hook_update_index |
developer/ |
Update Drupal's full-text index for this module. |
hook_update |
developer/ |
Respond to node updating. |
hook_uninstall |
developer/ |
Remove any information that the module sets. |
hook_translation_link_alter |
developer/ |
Perform alterations on translation links. |
hook_translated_menu_link_alter |
developer/ |
Alter a menu link after it's translated, but before it's rendered. |
hook_theme_registry_alter |
developer/ |
Alter the theme registry information returned from hook_theme(). |
hook_theme |
developer/ |
Register a module (or theme's) theme implementations. |
hook_term_path |
developer/ |
Allows modules to provide an alternative path for the terms it manages. |
hook_taxonomy |
developer/ |
Act on taxonomy changes. |
hook_system_info_alter |
developer/ |
Alter the information parsed from module and theme .info files |
hook_search_preprocess |
developer/ |
Preprocess text for the search index. |
hook_search_page |
developer/ |
Override the rendering of search results. |
hook_search |
developer/ |
Define a custom search routine. |
hook_schema_alter |
developer/ |
Performs alterations to existing database schemas. |
hook_schema |
developer/ |
Define the current version of the database schema. |
hook_requirements |
developer/ |
Check installation requirements and do status reporting. |
hook_profile_alter |
developer/ |
Alter profile items before they are rendered. |
hook_preprocess_HOOK |
developer/ |
Preprocess theme variables for a specific theme hook. |
hook_preprocess |
developer/ |
Preprocess theme variables for template files. |
hook_prepare |
developer/ |
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_ping |
developer/ |
Ping another server. |
hook_perm |
developer/ |
Define user permissions. |
hook_openid |
developer/ |
Allow modules to modify the OpenID request parameters. |
hook_node_type |
developer/ |
Act on node type changes. |
hook_node_operations |
developer/ |
Add mass node operations. |
hook_node_info |
developer/ |
Define module-provided node types. |
hook_node_grants |
developer/ |
Inform the node access system what permissions the user has. |
hook_node_access_records |
developer/ |
Set permissions for a node to be written to the database. |
hook_nodeapi |
developer/ |
Act on nodes defined by other modules. |
hook_menu_link_alter |
developer/ |
Alter the data being saved to the {menu_links} table by menu_link_save(). |
hook_menu_alter |
developer/ |
Alter the data being saved to the {menu_router} table after hook_menu is invoked. |
hook_menu |
developer/ |
Define menu items and page callbacks. |
hook_mail_alter |
developer/ |
Alter any aspect of email sent by Drupal. You can use this hook to add a common site footer to all outgoing email, add extra header fields, and/or modify the email in any way. HTML-izing the outgoing email is one possibility. See also drupal_mail(). |
hook_mail |
developer/ |
Prepare a message based on parameters; called from drupal_mail(). |
hook_locale |
developer/ |
Allows modules to define their own text groups that can be translated. |
hook_load |
developer/ |
Load node-type-specific information. |
hook_link_alter |
developer/ |
Perform alterations before links on a node or comment are rendered. |
hook_link |
developer/ |
Define internal Drupal links. |
hook_install |
developer/ |
Install the current version of the database schema, and any other setup tasks. |
hook_insert |
developer/ |
Respond to node insertion. |
hook_init |
developer/ |
Perform setup tasks. See also, hook_boot. |
hook_hook_info |
developer/ |
Expose a list of triggers (events) that users can assign actions to. |
hook_help |
developer/ |
Provide online user help. |
hook_form_FORM_ID_alter |
developer/ |
Provide a form-specific alteration instead of the global hook_form_alter(). |
hook_form_alter |
developer/ |
Perform alterations before a form is rendered. |
hook_forms |
developer/ |
Map form_ids to builder functions. |
hook_form |
developer/ |
Display a node editing form. |
hook_footer |
developer/ |
Insert closing HTML. |
hook_flush_caches |
developer/ |
Add a list of cache tables to be cleared. |
hook_filter_tips |
developer/ |
Provide tips for using filters. |
hook_filter |
developer/ |
Define content filters. |
hook_file_download |
developer/ |
Control access to private file downloads and specify HTTP headers. |
hook_exit |
developer/ |
Perform cleanup tasks. |
hook_enable |
developer/ |
Perform necessary actions after module is enabled. |
hook_elements |
developer/ |
Allows modules to declare their own Forms API element types and specify their default values. |
hook_disable |
developer/ |
Perform necessary actions before module is disabled. |
hook_delete |
developer/ |
Respond to node deletion. |
hook_db_rewrite_sql |
developer/ |
Rewrite database queries, usually for access control. |
hook_cron |
developer/ |
Perform periodic actions. |
hook_comment |
developer/ |
Respond to comment actions. |
hook_boot |
developer/ |
Perform setup tasks. See also, hook_init. |
hook_block |
developer/ |
Declare a block or set of blocks. |
hook_action_info_alter |
developer/ |
Alter the actions declared by another module. |
hook_action_info |
developer/ |
Declare information about one or more Drupal actions. |
hook_actions_delete |
developer/ |
Execute code after an action is deleted. |
hook_access |
developer/ |
Define access restrictions. |
custom_url_rewrite_outbound |
developer/ |
custom_url_rewrite_outbound is not a hook, it's a function you can add to settings.php to alter all links generated by Drupal. This function is called from url(). This function is called very frequently (100+ times per page) so performance… |
custom_url_rewrite_inbound |
developer/ |
custom_url_rewrite_inbound is not a hook, it's a function you can add to settings.php to alter incoming requests so they map to a Drupal path. This function is called before modules are loaded and the menu system is initialized and it changes… |