[development] About hook_action_info()

Vandyk, John K [ENT] jvandyk at iastate.edu
Tue Jul 13 13:46:44 UTC 2010

That does not look like an implementation of hook_action_info(). For an example implementation, see


It looks like you are actually writing an action. In that case, the first parameter is populated by the native object that the action is working on. For example, if you are triggering an unpublish action when a node is edited, the object that you are working on is a node, and the trigger system will send the node object along to the action call as the first parameter.

However, if you want to do something crazy like unpublish a node when a comment is submitted, you are acting on a comment object, not a node object. If you run an unpublish node action in that case, the trigger system will expend a little effort trying to make sure that the unpublish-a-node action (which works on nodes) gets a node. See


Since some actions can be called in multiple contexts, you will see them doing gyrations like this:


The short answer is, ask yourself whether your action will ever be used in a weird context, and if you might have to pluck the $node from the $context or do a node_load() from some information in the context that could lead you to the node.

On Jul 13, 2010, at 12:52 AM, icerain wrote:

> When i implement hook_action_info(), i found the first para *$node* is empty.
> My question is 
> function mymodule_myaction_action(&$node, $context = array()) {
>     $node = $context['node']; // should this line be added?
> ...
> }
> Or something else error?
> -- 
> A decathlon Drupal developer & programmer
> http://blog.eood.cn/

More information about the development mailing list