You are on page 1of 2


x Core Hooks Cheat Sheet, valid as of January 20th, 2008

Hook Implementation in Core
A hook_access($op, $node, $account) modules/poll/poll.module
Define access restrictions.
B hook_block($op = 'list', $delta = 0, $edit = array()) modules/comment/comment.module
Declare a block or set of blocks.
hook_boot() N/A
Perform setup tasks. See also, hook_init.
C hook_comment($a1, $op) modules/user/user.module
Act on comments.
hook_cron() modules/search/search.module
Perform periodic actions.
D hook_db_rewrite_sql($query, $primary_table, $primary_field, $args) modules/node/node.module
Rewrite database queries, usually for access control.
hook_delete(&$node) modules/poll/poll.module
Respond to node deletion.
hook_disable() N/A
Perform necessary actions before module is disabled.
E hook_elements() modules/system/system.module
Allows modules to declare their own form element types and specify their default values.
hook_enable() modules/menu/menu.module
Perform necessary actions after module is enabled.
hook_exit($destination = NULL) modules/statistics/statistics.module
Perform cleanup tasks.
F hook_file_download($file) modules/user/user.module
Allow file downloads.
hook_filter($op, $delta = 0, $format = -1, $text = '') modules/filter/filter.module
Define content filters.
hook_filter_tips($delta, $format, $long = false) modules/filter/filter.module
Provide tips for using filters.
hook_footer($main = 0) N/A
Insert closing HTML.
hook_form(&$node, &$param) modules/search/search.module
Display a node editing form.
hook_forms() modules/search/search.module
Map form_ids to builder functions.
hook_form_alter(&$form, $form_state, $form_id) modules/locale/locale.module
Perform alterations before a form is rendered.
H hook_help($path, $arg) modules/openid/openid.module,
Provide online user help.
I hook_init() modules/forum/forum.module
Perform setup tasks. See also, hook_boot.
hook_insert($node) modules/poll/poll.module
Respond to node insertion.
hook_install() N/A
Install the current version of the database schema, and any other setup tasks.
L hook_link($type, $object, $teaser = FALSE) modules/node/node.module
Define internal Drupal links.
hook_link_alter(&$links, $node) modules/forum/forum.module
Perform alterations before links on a node are rendered. One popular use of this hook is to
add/delete links from other modules.
hook_load($node) modules/path/path.module
Load node-type-specific information.
M hook_mail($key, &$message, $params) modules/update/update.module
Prepare a message based on parameters. See drupal_mail for more.
hook_mail_alter(&$message) N/A
Alter any aspect of the emails sent by Drupal
hook_menu() modules/path/path.module
Define menu items and page callbacks.
hook_menu_alter(&$callbacks) modules/upload/upload.module
Alter the data being saved to the {menu_router} table after hook_menu is invoked.
hook_menu_link_alter(&$item, $menu) modules/forum/forum.module
Alter the data being saved to the {menu_links} table by menu_link_save().

Licensed under Creative Commons Attribution-Share Alike 2.0
By kourge.
6.x Core Hooks Cheat Sheet, valid as of January 20th, 2008

Hook Implementation in Core
N hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) modules/path/path.module
Act on nodes defined by other modules.
hook_node_access_records($node) N/A
Set permissions for a node to be written to the database.
hook_node_grants($account, $op) N/A
Inform the node access system what permissions the user has.
hook_node_info() modules/poll/poll.module
Define module-provided node types. modules/blog/blog.module
hook_node_operations() modules/node/
Add mass node operations.
hook_node_type($op, $info) modules/taxonomy/taxonomy.module
Act on node type changes.
P hook_perm() modules/search/search.module
Define user permissions.
hook_ping($name = '', $url = '') modules/ping/ping.module
Ping another server.
hook_prepare(&$node) modules/node/node.module
This 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_alter(&$fields, $account) N/A
Perform alterations profile items before they are rendered. You may omit/add/re-sort/re-
categorize, etc.
R hook_requirements($phase) modules/update/update.module
Check installation requirements and do status reporting.
S hook_schema() N/A
Define the current version of the database schema.
hook_search($op = 'search', $keys = null) modules/user/user.module
Define a custom search routine.
hook_search_item($item) N/A
Format a search result.
hook_search_preprocess($text) N/A
Preprocess text for the search index.
hook_submit(&$node) modules/node/node.module
This 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.
T hook_taxonomy($op, $type, $array = NULL) modules/forum/forum.module
Act on taxonomy changes.
hook_theme() modules/search/search.module
Register a module’s (or theme’s) theme implementations.
U hook_uninstall() N/A
Remove any tables or variables that the module sets.
hook_update($node) modules/poll/poll.module
Respond to node updating.
hook_update_index() modules/node/node.module
Update Drupal’s full-text index for this module.
hook_update_N() N/A
Perform 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_user($op, &$edit, &$account, $category = NULL) modules/dblog/dblog.module
Act on user account actions.
hook_user_operations() modules/user/user.module
Add mass user operations.
V hook_validate($node) modules/poll/poll.module
Verify a node editing form.
hook_view($node, $teaser = FALSE, $page = FALSE) modules/poll/poll.module
Display a node.
W hook_watchdog($log_msg) modules/dblog/dblog.module
Log an event message
X hook_xmlrpc() modules/blogapi/blogapi.module
Register XML-RPC callbacks.

Licensed under Creative Commons Attribution-Share Alike 2.0
By kourge.