Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 5

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_rewritedocumentation/hooks/core.phpcustom_url_rewrite is not a hook, it's a function you can add to settings.php to manage aliases with some code.
hook_accessdocumentation/hooks/node.phpDefine access restrictions.
hook_add_to_cartcontributions/ubercart/docs/hooks.phpDo extra processing when an item is added to the shopping cart.
hook_add_to_cart_datacontributions/ubercart/docs/hooks.phpAdd extra information to a cart item's "data" array.
hook_authdocumentation/hooks/authentication.phpVerify authentication of a user.
hook_blockdocumentation/hooks/core.phpDeclare a block or set of blocks.
hook_calculate_taxcontributions/ubercart/docs/hooks.phpCalculate tax line items for an order.
hook_cart_displaycontributions/ubercart/docs/hooks.phpControl the display of an item in the cart.
hook_cart_itemcontributions/ubercart/docs/hooks.phpAdd extra data about an item in the cart.
hook_cart_panecontributions/ubercart/docs/hooks.phpRegister callbacks for a cart pane.
hook_checkout_panecontributions/ubercart/docs/hooks.phpRegister callbacks for a checkout pane.
hook_commentdocumentation/hooks/core.phpAct on comments.
hook_crondocumentation/hooks/core.phpPerform periodic actions.
hook_db_rewrite_sqldocumentation/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_deletedocumentation/hooks/node.phpRespond to node deletion.
hook_disabledocumentation/hooks/install.phpPerform necessary actions before module is disabled.
hook_download_authorizecontributions/ubercart/docs/hooks.phpGive clearance to a user to download a file.
hook_elementsdocumentation/hooks/core.phpAllows modules to declare their own form 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_fieldcontributions/cck/field.phpDefine the behavior of a field type.
hook_field_formattercontributions/cck/field.phpPrepare an individual item for viewing in a browser.
hook_field_formatter_infocontributions/cck/field.phpDeclare information about a formatter.
hook_field_infocontributions/cck/field.phpDeclare information about a field type.
hook_field_settingscontributions/cck/field.phpHandle the parameters for a field.
hook_file_actioncontributions/ubercart/docs/hooks.phpPerform actions on file products.
hook_file_downloaddocumentation/hooks/core.phpAllow file downloads.
hook_file_transfer_altercontributions/ubercart/docs/hooks.phpMake changes to a file before it is downloaded by the customer.
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_gmapcontributions/gmap/gmap.phpChange the way gmap works.
hook_helpdocumentation/hooks/core.phpProvide online user help.
hook_infodocumentation/hooks/authentication.phpDeclare authentication scheme information.
hook_initdocumentation/hooks/core.phpPerform setup tasks.
hook_insertdocumentation/hooks/node.phpRespond to node insertion.
hook_installdocumentation/hooks/install.phpInstall the current version of the database schema.
hook_line_itemcontributions/ubercart/docs/hooks.phpUsed to define line items that are attached to orders.
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_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_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_ordercontributions/ubercart/docs/hooks.phpPerform actions on orders.
hook_order_actionscontributions/ubercart/docs/hooks.phpAdd links to local tasks for orders on the admin's list of orders.
hook_order_panecontributions/ubercart/docs/hooks.phpRegister callbacks for an order pane.
hook_payment_gatewaycontributions/ubercart/docs/hooks.phpRegister payment gateway callbacks. See also@link http://www.ubercart.org/docs/api/hook_payment_gateway @endlink
hook_payment_methodcontributions/ubercart/docs/hooks.phpRegister callbacks for payment methods.
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_product_classcontributions/ubercart/docs/hooks.phpPerform actions on product classes.
hook_product_typescontributions/ubercart/docs/hooks.phpList node types which should be considered products.
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 that need to be satisfied.
hook_searchdocumentation/hooks/core.phpDefine a custom search routine.
hook_search_preprocessdocumentation/hooks/core.phpPreprocess text for the search index.
hook_shipmentcontributions/ubercart/docs/hooks.phpHandle additional data for shipments.
hook_shipping_methodcontributions/ubercart/docs/hooks.phpDefine callbacks and service options for shipping methods.
hook_shipping_typecontributions/ubercart/docs/hooks.phpDefine shipping types for shipping methods.
hook_store_statuscontributions/ubercart/docs/hooks.phpAdd status messages to the "Store administration" page.
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_uc_messagecontributions/ubercart/docs/hooks.phpConvenience function to display large blocks of text in several places.
hook_uninstalldocumentation/hooks/install.phpRemove any tables or variables that the module sets.
hook_updatedocumentation/hooks/node.phpRespond to node updating.
hook_update_cart_itemcontributions/ubercart/docs/hooks.phpHandle requests to update a cart item.
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_widgetcontributions/cck/field.phpDefine the behavior of a widget.
hook_widget_infocontributions/cck/field.phpDeclare information about a widget.
hook_widget_settingscontributions/cck/field.phpHandle the parameters for a widget.
hook_xmlrpcdocumentation/hooks/core.phpRegister XML-RPC callbacks.
hook_xmlsitemap_enginescontributions/xmlsitemap/docs/xmlsitemap.phpDefine actions for search engines.
hook_xmlsitemap_linkscontributions/xmlsitemap/docs/xmlsitemap.phpDefine additional links to add to the site map.
module_hook5/includes/module.incDetermine whether a module implements a hook.
module_implements5/includes/module.incDetermine which modules are implementing a hook.
module_invoke5/includes/module.incInvoke a hook in a particular module.
module_invoke_all5/includes/module.incInvoke a hook in all enabled modules that implement it.