Using actions

The Beans Actions API extends the WordPress Actions API by registering each action with a unique ID. This makes it easy to modify, replace, remove or reset actions using only the ID, regardless of whether the actions arguments have been changed.

Once an action is added with a unique id using beans_add_action() or beans_add_smart_action(), multiple functions can be used to manipulate it:


The example below hooks a title and a description using beans_add_action().

beans_add_action( 'my_page_title', 'action_hook', 'add_page_title' );

function add_page_title() {

 echo '<h1>Title</h1>';

beans_add_action( 'my_page_description', 'action_hook', 'add_page_description' );

function add_page_description() {

 echo '<p>Description</p>';

Once added, the actions can me manipulated via a child theme or plugin. For instance, the description could be moved above the title by modifying the action priority using beans_modify_action_priority().

beans_modify_action_priority( 'my_page_description', 5 );

Since both title and description actions where registered with the priority 10 (WordPress default), changing the description’s action priority to 5 will make it run first and therefore display it above the title. Note that only the action_id is needed here.

The title content could be overwritten by changing the action callback using beans_modify_action_callback().

beans_modify_action_callback( 'my_page_title', 'modify_page_title' );

function modify_page_title() {

  echo '<p>New title</p>';

The original could then be reset using beans_reset_action().

beans_reset_action( 'my_page_description' );

The line above would reset the action to how it was originally added, therefore it would display the description below the title.

If the description isn’t wanted, it can be removed using beans_remove_action().

beans_remove_action( 'my_page_description' );


Beans actions makes it very easy to add and manipulate actions. Furthermore, since only the action_id is needed to manipulate them, developers can add arguments without worrying about breaking their users modifications.