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_accessdocs-4-7/hooks/node.phpDefine access restrictions.
hook_blockdocs-4-7/hooks/core.phpDeclare a block or set of blocks.
hook_commentdocs-4-7/hooks/core.phpAct on comments.
hook_crondocs-4-7/hooks/core.phpPerform periodic actions.
hook_db_rewrite_sqldocs-4-7/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. Primary...
hook_deletedocs-4-7/hooks/node.phpRespond to node deletion.
hook_elementsdocs-4-7/hooks/core.phpAllows modules to declare their own form element types and specify their default values.
hook_exitdocs-4-7/hooks/core.phpPerform cleanup tasks.
hook_file_downloaddocs-4-7/hooks/core.phpAllow file downloads.
hook_filterdocs-4-7/hooks/core.phpDefine content filters.
hook_filter_tipsdocs-4-7/hooks/core.phpProvide tips for using filters.
hook_footerdocs-4-7/hooks/core.phpInsert closing HTML.
hook_formdocs-4-7/hooks/node.phpDisplay a node editing form.
hook_form_alterdocs-4-7/hooks/core.phpPerform alterations before a form is rendered. One popular use of this hook is to add form elements to the node form.
hook_helpdocs-4-7/hooks/core.phpProvide online user help.
hook_initdocs-4-7/hooks/core.phpPerform setup tasks.
hook_insertdocs-4-7/hooks/node.phpRespond to node insertion.
hook_linkdocs-4-7/hooks/core.phpDefine internal Drupal links.
hook_loaddocs-4-7/hooks/node.phpLoad node-type-specific information.
hook_menudocs-4-7/hooks/core.phpDefine menu items and page callbacks.
hook_nodeapidocs-4-7/hooks/core.phpAct on nodes defined by other modules.
hook_node_grantsdocs-4-7/hooks/core.phpGrant access to nodes.
hook_node_infodocs-4-7/hooks/node.phpDefine the human-readable name of a node type.
hook_permdocs-4-7/hooks/core.phpDefine user permissions.
hook_pingdocs-4-7/hooks/core.phpPing another server.
hook_preparedocs-4-7/hooks/node.phpThis is a hook used by node modules. It is called after load but before the node is shown on the add/edit form.
hook_searchdocs-4-7/hooks/core.phpDefine a custom search routine.
hook_search_preprocessdocs-4-7/hooks/core.phpPreprocess text for the search index.
hook_settingsdocs-4-7/hooks/core.phpDeclare administrative settings for a module.
hook_submitdocs-4-7/hooks/node.phpThis 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_taxonomydocs-4-7/hooks/core.phpAct on taxonomy changes.
hook_updatedocs-4-7/hooks/node.phpRespond to node updating.
hook_update_indexdocs-4-7/hooks/core.phpUpdate Drupal's full-text index for this module.
hook_userdocs-4-7/hooks/core.phpAct on user account actions.
hook_validatedocs-4-7/hooks/node.phpVerify a node editing form.
hook_viewdocs-4-7/hooks/node.phpDisplay a node.
hook_xmlrpcdocs-4-7/hooks/core.phpRegister XML-RPC callbacks.