Last updated 1 August 2015. Created on 11 May 2009.
Edited by drupalshrek, partyka, yannis_p, Ayesh. Log in to edit this page.

This guide applies to Drupal 6 only, last updated for release 6.x-1.13. There is a Drupal 7 VBO development guide available. Please note that the Drupal 6 version of VBO is no longer safe to use. (Read the Security Advisory)

Developing operations for VBO

VBO reuses existing Drupal infrastructure to allow new operations to be added. The main method to create a new operation is by writing a Drupal Action. Please read the linked page first. VBO supports a superset of the capabilities of actions, so here are the steps to create an action that fully utilizes VBO.

Implement hook_action_info()

VBO supports a superset of the attributes that describe an action. Here are the added attributes:

  • parameters (optional): keyed array. This attribute gets appended as is to the $context array that is passed to action_function().
  • behavior (optional): array of flags. This attribute exists in the original Action specification, but is augmented here with additional flags:
    • views_node_property to signify that this action will show the node on-screen.
    • deletes_node_property to signify that this action might delete the node.

    These flags, along with the original changes_node_property, cause VBO to call node_access() on each node that is about to be acted upon, with the $op parameter corresponding to the specified flag(s). If VBO is invoked in direct execution mode or through Batch API, the current user's permissions are checked against the required node access. If a deferred execution mode such as Job Queue is used, then the uid of the user who fired the job is used.

  • permissions (optional): array of permissions. VBO calls user_access on each permission before accepting to execute the selected action.
  • aggregate (optional): boolean. If TRUE, all selected objects' IDs (oids) will be packed in an array and passed as the first argument to the action function, instead of passing each object one by one. This is useful to implement aggregate functions that perform a single operation on the whole selection set.

Implement action_function(&$object, $context)


Implement action_function_form($context)


Implement action_function_submit($form, $form_state)


Implement action_function_validate($form, $form_state)


Implement action_function_views_bulk_operations_form($settings, $entityType, $settings_dom_id)

This hook allows you provide extra form items at configuration action form (when you add an action to the view).

 * Implements ACTION_FUNCTION_views_bulk_operations_form().
function action_function_views_bulk_operations_form($settings, $entityType, $settings_dom_id) {

  $settings += array(
    'set_tag' => array("bar"),

  $form['set_tag'] = array(
    '#title' => t('Set a tag by default'),
    '#type' => 'select',
    '#options' => array(
      "foo" => "foo",
      "bar" => "Bar"
    '#default_value' => $settings['set_tag'],

  return $form;

So, the "set_tag" will be available at action execution time (as $context key), then you will can use to apply your logic.

Describing operations for custom tables

First, you need to describe the action to Drupal. If the type is not a node or user, then you will have to create a new one and describe it with hook_views_bulk_operations_object_info.

 * Implements hook_action_info
function MODULE_action_info() {
  return array(
    'MODULE_ACTIONNAME_action' => array(
      'type' => 'OBJECTTYPE',
      'description' => t('ACTIONDESCRIPTION'),
      'configurable' => FALSE,
      'hooks' => array(
        'any' => TRUE,
      // Set to TRUE if you want to operate on an array of identifiers
      // Set to FALSE if you want to operate on each separately as an object
      'aggregate' => FALSE,

This is the glue that tells VBO what object to use with a particular table.

 * Implements hook_views_bulk_operations_object_info
function MODULE_views_bulk_operations_object_info() {
  return array(
    'OBJECTTYPE' => array(
      'type' => 'OBJECTTYPE',
      'base_table' => 'TABLENAME',
      'load' => '_OBJECTTYPELOAD',
      'title' => t('OBJECTTITLE'),

Define how the object is created.

 * Load an _OBJECTTYPE object; required for VBO
 * @param int $ID
 * @return object
  $sql_query  = 'SELECT * ';
  $sql_query .= 'FROM {TABLENAME} ';
  $sql_query .= 'WHERE ID = %d ';
  return db_fetch_object(db_query($sql_query, $ID));

Finally, perform the action.

 * Implementation of a Drupal action
 * @param object $object
 * @param array $context
function MODULE_ACTIONNAME_action(&$object, $context = array()) {
  // If aggregate is set to TRUE, $object will be an array containing the identifier.
  // Else, it will be the object from _OBJECTTYPELOAD
  dsm($object); // Debug the object with devel module
  dsm($context); // Debug the context with devel module

Looking for support? Visit the forums, or join #drupal-support in IRC.


mradcliffe’s picture

This is just a rough bit of text that I'll add via comment instead of reworking the above document:

  • hook_views_bulk_operations_object_info()
    • If you're using actions or operations outside of nodes or users you need to define this so that VBO can pass the correct object into your action or operation. Drupal actions, by unfortunate oversight, do not support objects other than node or user.
  • hook_OBJECT_operations()
    • This is similar to node_operations or user_operations, where OBJECT is an object defined in hook_views_bulk_operations_object_info() above. This will allow you to operate on multiple objects at once instead of just one, which is a limitation of Drupal actions. There is no documentation on this hook and you cannot grep/search for it because the function is built dynamically.
nileshbarve13’s picture


Just need some help from you regarding the following issue.

I have a created a view from a drupal database table using the data module with views and VBO.
The data module allows you to create a view from the adopted table.
when I go to the views and edit the view added through the data module, i see no multi-checkbox list under selected operations.

I want to have all the operations that are available under the node view type to be available here, for my view created with data module. (views created with data module have a view type data table)

I tried creating a new .inc file with custom actions under views_bulk_operations folder but these actions show only under view type node and not under data table views selected operations. (referred your comments on taxonomy -

Any help greatly appreciated.
Please help me ...
it's very very urgent.

Nilesh Barve

muka’s picture

 * hook_OBJECTTYPE_operations
 * - OBJECTTYPE as defined in hook_views_bulk_operations_object_info
 * - your action will be listed in the VBO view display settings form only if the view's base table is the same as the one defined in the hook above
function hook_OBJECTTYPE_operations() {

  return array(
    'do_something' => array(
      'label'               => t('Do something from view'),
      // Required
      'callback'            => '_do_something_callback',
      'behavior'            => array(),
      'permissions'         => array('some permission'),
      'callback arguments'  => array(),
      'configurable'        => FALSE,
      'form properties'     => array(),
      'source'              => 'operation',
      'aggregate'           => VBO_AGGREGATE_OPTIONAL,
      'hooks'               => array('any'=> TRUE),
Sussanna’s picture

Hello boys:

I have a question about VBO.
I need to select multiple pages to add in a book, however I don´t know how to do it.

How I can do?

thnx for advantage!

mradcliffe’s picture

I'm not sure if there is a module that provides Book actions.

infojunkie’s picture

VBO 6.x-1.11-beta1 has 2 actions for books.

Sussanna’s picture

Is there no book actions in version 7.x?


infojunkie’s picture

Not at the moment. Feel free to open a feature request.

Sussanna’s picture

Ok, I will do it.
Thank you very much for your answers!

Sussanna’s picture

Hey guys:

I'm trying to update the vbo 7.x content view that I have modified. So if I´m not wrong I must go to path module and modify the existing path "admin/content" to "admin/content2".

However, when I´m going to admin content page, the changes have not been made.

Can anyone tell me if I did correctly?


milesw’s picture

Those looking for Drupal 7 specific documentation on creating actions for VBO, check out the Examples module, where you'll find action_example.module

fp’s picture

Note that permissions for custom actions are generated dynamically. If you have setup a default administrative role and expect to have access to the newly created permission automatically, you are mistaken.

Unless you manually assign the permission to the appropriate role, you will see your action in the Views config but your action will not show up on the View form.

Ramananda Panda’s picture

in bulk operations can I pass the selected values to the next page in the url like in $_GET.
like in the url,student_id.