function hook_action_info

You are here

7 system.api.php hook_action_info()
6 core.php hook_action_info()

Declare information about one or more Drupal actions.

Any module can define any number of Drupal actions. The trigger module is an example of a module that uses actions. An action consists of two or three parts: (1) an action definition (returned by this hook), (2) a function which does the action (which by convention is named module + '_' + description of what the function does + '_action'), and an optional form definition function that defines a configuration form (which has the name of the action with '_form' appended to it.)

Return value

  • An array of action descriptions. Each action description is an associative array, where the key of the item is the action's function, and the following key-value pairs:

    • 'type': (required) the type is determined by what object the action acts on. Possible choices are node, user, comment, and system. Or whatever your own custom type is. So, for the nodequeue module, the type might be set to 'nodequeue' if the action would be performed on a nodequeue.
    • 'description': (required) The human-readable name of the action.
    • 'configurable': (required) If FALSE, then the action doesn't require any extra configuration. If TRUE, then you should define a form function with the same name as the key, but with '_form' appended to it (i.e., the form for 'node_assign_owner_action' is 'node_assign_owner_action_form'.) This function will take the $context as the only parameter, and is paired with the usual _submit function, and possibly a _validate function.
    • 'hooks': (required) An array of all of the operations this action is appropriate for, keyed by hook name. The trigger module uses this to filter out inappropriate actions when presenting the interface for assigning actions to events. If you are writing actions in your own modules and you simply want to declare support for all possible hooks, you can set 'hooks' => array('any' => TRUE). Common hooks are 'user', 'nodeapi', 'comment', or 'taxonomy'. Any hook that has been described to Drupal in hook_hook_info() will work is a possiblity.
    • 'behavior': (optional) Human-readable array of behavior descriptions. The only one we have now is 'changes node property'. You will almost certainly never have to return this in your own implementations of this hook.

The function that is called when the action is triggered is passed two parameters - an object of the same type as the 'type' value of the hook_action_info array, and a context variable that contains the context under which the action is currently running, sent as an array. For example, the actions module sets the 'hook' and 'op' keys of the context array (so, 'hook' may be 'nodeapi' and 'op' may be 'insert').

Related topics

4 functions implement hook_action_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

comment_action_info in modules/comment/comment.module
Implementation of hook_action_info().
node_action_info in modules/node/node.module
Implementation of hook_action_info().
system_action_info in modules/system/system.module
Implementation of hook_action_info().
user_action_info in modules/user/user.module
Implementation of hook_action_info().
1 invocation of hook_action_info()
actions_list in includes/
Discover all action functions by invoking hook_action_info().


developer/hooks/core.php, line 67
These are the hooks that are invoked by the Drupal core.


function hook_action_info() {
  return array(
    'comment_unpublish_action' => array(
      'description' => t('Unpublish comment'),
      'type' => 'comment',
      'configurable' => FALSE,
      'hooks' => array(
        'comment' => array('insert', 'update'),
    'comment_unpublish_by_keyword_action' => array(
      'description' => t('Unpublish comment containing keyword(s)'),
      'type' => 'comment',
      'configurable' => TRUE,
      'hooks' => array(
        'comment' => array('insert', 'update'),


To allow a new action to appear on the Triggers page, you will need to visit the Action admin page (/admin/settings/actions) or call actions_synchronize().

To remove a deleted ("orphaned") Action from the Triggers page, visit /admin/settings/actions/orphan or call system_actions_remove_orphans().

Wow, you are the man! I was desperate to figure out why my actions do not show up under Triggers page for an hour or so before I saw your comment. Flushing caches does not help, indeed you have to visit those pages or execute those functions :(