Skip navigation


  1. drupal
    1. 6 drupal/includes/
    2. 7 drupal/includes/

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().

Functions & methods

custom_url_rewrite_inboundcustom_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_outboundcustom_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_accessDefine access restrictions.
hook_actions_deleteExecute code after an action is deleted.
hook_action_infoDeclare information about one or more Drupal actions.
hook_action_info_alterAlter the actions declared by another module.
hook_add_to_cartPerforms extra processing when an item is added to the shopping cart.
hook_add_to_cart_dataAdds extra information to a cart item's "data" array.
hook_blockDeclare a block or set of blocks.
hook_bootPerform setup tasks. See also, hook_init.
hook_calculate_taxCalculates tax line items for an order.
hook_cart_displayControls the display of an item in the cart.
hook_cart_itemAdds extra data about an item in the cart.
hook_cart_paneRegisters callbacks for a cart pane.
hook_cart_pane_alterAlters cart pane definitions.
hook_checkout_paneRegisters callbacks for a checkout pane.
hook_checkout_pane_alterAlters checkout pane definitions.
hook_commentRespond to comment actions.
hook_cronPerform periodic actions.
hook_db_rewrite_sqlRewrite database queries, usually for access control.
hook_deleteRespond to node deletion.
hook_disablePerform necessary actions before module is disabled.
hook_download_authorizeGives clearance to a user to download a file.
hook_elementsAllows modules to declare their own Forms API element types and specify their default values.
hook_enablePerform necessary actions after module is enabled.
hook_exitPerform cleanup tasks.
hook_file_actionPerforms actions on file products.
hook_file_downloadControl access to private file downloads and specify HTTP headers.
hook_file_transfer_alterMakes changes to a file before it is downloaded by the customer.
hook_filterDefine content filters.
hook_filter_tipsProvide tips for using filters.
hook_flush_cachesAdd a list of cache tables to be cleared.
hook_footerInsert closing HTML.
hook_formDisplay a node editing form.
hook_formsMap form_ids to builder functions.
hook_form_alterPerform alterations before a form is rendered.
hook_form_FORM_ID_alterProvide a form-specific alteration instead of the global hook_form_alter().
hook_helpProvide online user help.
hook_hook_infoExpose a list of triggers (events) that users can assign actions to.
hook_initPerform setup tasks. See also, hook_boot.
hook_insertRespond to node insertion.
hook_installInstall the current version of the database schema, and any other setup tasks.
hook_line_itemDefines line items that are attached to orders.
hook_line_item_alterAlters a line item on an order when the order is loaded.
hook_line_item_data_alterAlters the line item definitions declared in hook_line_item().
hook_linkDefine internal Drupal links.
hook_link_alterPerform alterations before links on a node or comment are rendered.
hook_loadLoad node-type-specific information.
hook_localeAllows modules to define their own text groups that can be translated.
hook_mailPrepare a message based on parameters; called from drupal_mail().
hook_mail_alterAlter 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_menuDefine menu items and page callbacks.
hook_menu_alterAlter the data being saved to the {menu_router} table after hook_menu is invoked.
hook_menu_link_alterAlter the data being saved to the {menu_links} table by menu_link_save().
hook_nodeapiAct on nodes defined by other modules.
hook_node_access_recordsSet permissions for a node to be written to the database.
hook_node_grantsInform the node access system what permissions the user has.
hook_node_infoDefine module-provided node types.
hook_node_operationsAdd mass node operations.
hook_node_typeAct on node type changes.
hook_openidAllow modules to modify the OpenID request parameters.
hook_orderPerforms actions on orders.
hook_order_actionsAdds links to local tasks for orders on the admin's list of orders.
hook_order_paneRegisters callbacks for an order pane.
hook_order_pane_alterAlters order pane definitions.
hook_order_product_alterAllows modules to alter ordered products when they're loaded with an order.
hook_order_stateRegisters static order states.
hook_payment_gatewayRegisters payment gateway callbacks.
hook_payment_gateway_alterAlters payment gateways.
hook_payment_gateway_chargeCredit card charge callback.
hook_payment_methodRegisters callbacks for payment methods.
hook_payment_method_alterAlter payment methods.
hook_payment_method_callbackCallback function to perform various operations for a payment method.
hook_permDefine user permissions.
hook_pingPing another server.
hook_prepareThis is a hook used by node modules. It is called after load but before the node is shown on the add/edit form.
hook_product_classPerforms actions on product classes.
hook_product_descriptionReturns a structured array representing the given product's description.
hook_product_description_alterAlters the given product description.
hook_product_typesLists node types which should be considered products.
hook_profile_alterAlter profile items before they are rendered.
hook_requirementsCheck installation requirements and do status reporting.
hook_schemaDefine the current version of the database schema.
hook_schema_alterPerforms alterations to existing database schemas.
hook_searchDefine a custom search routine.
hook_search_preprocessPreprocess text for the search index.
hook_shipmentHandles additional data for shipments.
hook_shipping_methodDefines callbacks and service options for shipping methods.
hook_shipping_typeDefines shipping types for shipping methods.
hook_store_statusAdds status messages to the "Store administration" page.
hook_system_info_alterAlter the information parsed from module and theme .info files
hook_tapir_table_alterAllows modules to alter the TAPIr table after the rows are populated.
hook_tapir_table_header_alterAllows modules to alter TAPIr table headers.
hook_taxonomyAct on taxonomy changes.
hook_term_pathAllows modules to provide an alternative path for the terms it manages.
hook_themeRegister a module (or theme's) theme implementations.
hook_theme_registry_alterAlter the theme registry information returned from hook_theme().
hook_token_listProvide metadata about available placeholder tokens and token types.
hook_token_valuesProvide replacement values for placeholder tokens.
hook_translated_menu_link_alterAlter a menu link after it's translated, but before it's rendered.
hook_translation_link_alterPerform alterations on translation links.
hook_ucga_displayDetermines whether or not UC Google Analytics should add e-commerce tracking code to the bottom of the page.
hook_ucga_item_alterAllows modules to alter items before they're added to the UC Google Analytics e-commerce tracking code.
hook_ucga_trans_alterAllows modules to alter transaction info before it's added to the UC Google Analytics e-commerce tracking code.
hook_uc_checkout_completeTakes action when checkout is completed.
hook_uc_form_alterAllows modules to modify forms before Drupal invokes hook_form_alter().
hook_uc_invoice_templatesAdds invoice templates to the list of suggested template files.
hook_uc_messageConvenience function to display large blocks of text in several places.
hook_uc_payment_enteredTakes action when a payment is entered for an order.
hook_uc_price_handlerDefines price handlers for your module.
hook_uc_product_default_classesDefines default product classes.
hook_uc_product_modelsNotifies core of any SKUs your module adds to a given node.
hook_uc_roles_deleteAllows modules to react to the removal of an expiring role.
hook_uc_roles_grantAllows modules to react to the addition of an expiring role.
hook_uc_roles_renewAllows modules to react to the renewal of an expiring role.
hook_uc_stock_adjustedAllows modules to take action when a stock level is changed.
hook_uninstallRemove any information that the module sets.
hook_updateRespond to node updating.
hook_update_cart_itemHandles requests to update a cart item.
hook_update_indexUpdate Drupal's full-text index for this module.
hook_update_last_removedReturn a number which is no longer available as hook_update_N().
hook_update_NPerform a single update.
hook_update_projects_alterAlter the list of projects before fetching data and comparing versions.
hook_update_status_alterAlter the information about available updates for projects.
hook_userAct on user account actions.
hook_user_operationsAdd mass user operations.
hook_validateVerify a node editing form.
hook_viewDisplay a node.
hook_watchdogLog an event message
hook_xmlrpcRegister XML-RPC callbacks.
module_hookDetermine whether a module implements a hook.
module_implementsDetermine which modules are implementing a hook.
module_invokeInvoke a hook in a particular module.
module_invoke_allInvoke a hook in all enabled modules that implement it.
page_cache_fastpathOutputs a cached page.


drupal/includes/, line 364
API for loading and interacting with Drupal modules.