Contributions API

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
custom_url_rewrite_inbounddocumentation/hooks/core.phpcustom_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...
custom_url_rewrite_outbounddocumentation/hooks/core.phpcustom_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...
hook_accessdocumentation/hooks/node.phpDefine access restrictions.
hook_blockdocumentation/hooks/core.phpDeclare a block or set of blocks.
hook_bootdocumentation/hooks/core.phpPerform setup tasks. See also, hook_init.
hook_commentdocumentation/hooks/core.phpAct on comments.
hook_crondocumentation/hooks/core.phpPerform periodic actions.
hook_db_rewrite_sqldocumentation/hooks/core.phpRewrite database queries, usually for access control.
hook_deletedocumentation/hooks/node.phpRespond to node deletion.
hook_disabledocumentation/hooks/install.phpPerform necessary actions before module is disabled.
hook_elementsdocumentation/hooks/core.phpAllows modules to declare their own Forms API element types and specify their default values.
hook_enabledocumentation/hooks/install.phpPerform necessary actions after module is enabled.
hook_exitdocumentation/hooks/core.phpPerform cleanup tasks.
hook_file_downloaddocumentation/hooks/core.phpAllow file downloads.
hook_filterdocumentation/hooks/core.phpDefine content filters.
hook_filter_tipsdocumentation/hooks/core.phpProvide tips for using filters.
hook_footerdocumentation/hooks/core.phpInsert closing HTML.
hook_formdocumentation/hooks/node.phpDisplay a node editing form.
hook_formsdocumentation/hooks/core.phpMap form_ids to builder functions.
hook_form_alterdocumentation/hooks/core.phpPerform alterations before a form is rendered.
hook_helpdocumentation/hooks/core.phpProvide online user help.
hook_initdocumentation/hooks/core.phpPerform setup tasks. See also, hook_boot.
hook_insertdocumentation/hooks/node.phpRespond to node insertion.
hook_installdocumentation/hooks/install.phpInstall the current version of the database schema, and any other setup tasks.
hook_linkdocumentation/hooks/core.phpDefine internal Drupal links.
hook_link_alterdocumentation/hooks/core.phpPerform alterations before links on a node are rendered. One popular use of this hook is to add/delete links from other modules.
hook_loaddocumentation/hooks/node.phpLoad node-type-specific information.
hook_maildocumentation/hooks/core.phpPrepare a message based on parameters. @see drupal_mail for more.
hook_mail_alterdocumentation/hooks/core.phpAlter 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_menudocumentation/hooks/core.phpDefine menu items and page callbacks.
hook_menu_alterdocumentation/hooks/core.phpAlter the data being saved to the {menu_router} table after hook_menu is invoked.
hook_menu_link_alterdocumentation/hooks/core.phpAlter the data being saved to the {menu_links} table by menu_link_save().
hook_nodeapidocumentation/hooks/core.phpAct on nodes defined by other modules.
hook_node_access_recordsdocumentation/hooks/core.phpSet permissions for a node to be written to the database.
hook_node_grantsdocumentation/hooks/core.phpInform the node access system what permissions the user has.
hook_node_infodocumentation/hooks/node.phpDefine module-provided node types.
hook_node_operationsdocumentation/hooks/core.phpAdd mass node operations.
hook_node_typedocumentation/hooks/node.phpAct on node type changes.
hook_permdocumentation/hooks/core.phpDefine user permissions.
hook_pingdocumentation/hooks/core.phpPing another server.
hook_preparedocumentation/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_profile_alterdocumentation/hooks/core.phpPerform alterations profile items before they are rendered. You may omit/add/re-sort/re-categorize, etc.
hook_requirementsdocumentation/hooks/install.phpCheck installation requirements and do status reporting.
hook_schemadocumentation/hooks/install.phpDefine the current version of the database schema.
hook_searchdocumentation/hooks/core.phpDefine a custom search routine.
hook_search_preprocessdocumentation/hooks/core.phpPreprocess text for the search index.
hook_submitdocumentation/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_taxonomydocumentation/hooks/core.phpAct on taxonomy changes.
hook_themedocumentation/hooks/core.phpRegister a module (or theme's) theme implementations.
hook_translated_menu_link_alterdocumentation/hooks/core.phpAlter a menu link after it's translated, but before it's rendered.
hook_uninstalldocumentation/hooks/install.phpRemove any tables or variables that the module sets.
hook_updatedocumentation/hooks/node.phpRespond to node updating.
hook_update_indexdocumentation/hooks/core.phpUpdate Drupal's full-text index for this module.
hook_update_Ndocumentation/hooks/install.phpPerform a single update. For each patch which requires a database change add a new hook_update_N() which will be called by update.php.
hook_userdocumentation/hooks/core.phpAct on user account actions.
hook_user_operationsdocumentation/hooks/core.phpAdd mass user operations.
hook_validatedocumentation/hooks/node.phpVerify a node editing form.
hook_viewdocumentation/hooks/node.phpDisplay a node.
hook_watchdogdocumentation/hooks/core.phpLog an event message
hook_xmlrpcdocumentation/hooks/core.phpRegister XML-RPC callbacks.
module_hook6/includes/module.incDetermine whether a module implements a hook.
module_implements6/includes/module.incDetermine which modules are implementing a hook.
module_invoke6/includes/module.incInvoke a hook in a particular module.
module_invoke_all6/includes/module.incInvoke a hook in all enabled modules that implement it.
text_content_is_emptycontributions/cck/examples/simple_field.phpImplementation of hook_content_is_empty().
text_elementscontributions/cck/examples/example_field.phpImplementation of FAPI hook_elements().
text_fieldcontributions/cck/examples/simple_field.phpImplementation of hook_field().
text_field_formattercontributions/cck/examples/simple_field.phpImplementation of hook_field_formatter().
text_field_formatter_infocontributions/cck/examples/simple_field.phpImplementation of hook_field_formatter_info().
text_field_infocontributions/cck/examples/simple_field.phpImplementation of hook_field_info().
text_field_settingscontributions/cck/examples/simple_field.phpImplementation of hook_field_settings().
text_textarea_processcontributions/cck/examples/example_field.phpProcess an individual element.
text_textfield_processcontributions/cck/examples/example_field.phpProcess an individual element.
text_themecontributions/cck/examples/simple_field.phpImplementation of hook_theme().
text_widgetcontributions/cck/examples/simple_field.phpImplementation of hook_widget().
text_widget_infocontributions/cck/examples/simple_field.phpImplementation of hook_widget_info().
text_widget_settingscontributions/cck/examples/simple_field.phpImplementation of hook_widget_settings().
theme_text_textfieldcontributions/cck/examples/example_field.phpFAPI theme for an individual text elements.