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 iconLocationDescription
hook_accessdeveloper/hooks/node.phpDefine access restrictions.
hook_authdeveloper/hooks/authentication.phpVerify authentication of a user.
hook_blockdeveloper/hooks/core.phpDeclare a block or set of blocks.
hook_commentdeveloper/hooks/core.phpAct on comment modification.
hook_crondeveloper/hooks/core.phpPerform periodic actions.
hook_db_rewrite_sqldeveloper/hooks/core.phpAdd 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_deletedeveloper/hooks/node.phpRespond to node deletion.
hook_exitdeveloper/hooks/core.phpPerform cleanup tasks.
hook_filterdeveloper/hooks/core.phpDefine content filters.
hook_filter_tipsdeveloper/hooks/core.phpProvide tips for using filters.
hook_footerdeveloper/hooks/core.phpInsert closing HTML.
hook_formdeveloper/hooks/node.phpDisplay a node editing form.
hook_helpdeveloper/hooks/core.phpProvide online user help.
hook_infodeveloper/hooks/authentication.phpDeclare authentication scheme information.
hook_initdeveloper/hooks/core.phpPerform setup tasks.
hook_insertdeveloper/hooks/node.phpRespond to node insertion.
hook_linkdeveloper/hooks/core.phpDefine internal Drupal links.
hook_loaddeveloper/hooks/node.phpLoad node-type-specific information.
hook_menudeveloper/hooks/core.phpDefine menu items and page callbacks.
hook_nodeapideveloper/hooks/core.phpAct on nodes defined by other modules.
hook_node_grantsdeveloper/hooks/core.phpGrant access to nodes.
hook_node_namedeveloper/hooks/node.phpDefine the human-readable name of a node type.
hook_node_typesdeveloper/hooks/node.phpDefine multiple node types.
hook_onloaddeveloper/hooks/core.phpInsert a JavaScript onload handler.
hook_permdeveloper/hooks/core.phpDefine user permissions.
hook_pingdeveloper/hooks/core.phpPing another server.
hook_searchdeveloper/hooks/core.phpDefine a custom search routine.
hook_search_itemdeveloper/hooks/core.phpFormat a search result.
hook_search_preprocessdeveloper/hooks/core.phpPreprocess text for the search index.
hook_settingsdeveloper/hooks/core.phpDeclare administrative settings for a module.
hook_taxonomydeveloper/hooks/core.phpAct on taxonomy changes.
hook_textareadeveloper/hooks/core.phpReact to textarea additions.
hook_updatedeveloper/hooks/node.phpRespond to node updating.
hook_update_indexdeveloper/hooks/core.phpUpdate Drupal's full-text index for this module.
hook_userdeveloper/hooks/core.phpAct on user account actions.
hook_validatedeveloper/hooks/node.phpVerify a node editing form.
hook_viewdeveloper/hooks/node.phpDisplay a node.
hook_xmlrpcdeveloper/hooks/core.phpRegister XML-RPC callbacks.
module_hookincludes/module.incDetermine whether a module implements a hook.
module_implementsincludes/module.incDetermine which modules are implementing a hook.
module_invokeincludes/module.incInvoke a hook in a particular module.
module_invoke_allincludes/module.incInvoke a hook in all enabled modules that implement it.
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.