What is Drupal hook

9. What is Drupal hook?

The module system in Drupal is based on hook, which is nothing but a PHP function defining set of parameters and a specific result type. The hooks allow modules to interact with the Drupal core.


(i) hook_menu

The hook_menu defines menu items and page callbacks.

Syntax: hook_menu()


(ii) hook_nodeapi

hook_nodeapi() allows modules to react to actions affecting all kinds of nodes. It acts on nodes defined by other modules.

Syntax: hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL)


(iii) hook_form_alter

The hook_form_alter performs alterations before rendering a form in Drupal. One popular use of this particular hook is to add form elements to the node.

Syntax: hook_form_alter(&$form, $form_state, $form_id)


(iv) hook_user

The hook called hook_user lets modules react when operations are performed on user accounts.

Syntax: hook_user($op, &$edit, &$account, $category = NULL)


Drupal Hook