Create custom action for Views Bulk Operations

Public

In your custom module, define a action_info hook at first:

Get raw version
php
  1. /**
  2.  * Implements hook_action_info().
  3.  */
  4. function custom_action_info() {
  5. return array(
  6. 'custom_action_callback_name' => array(
  7. 'type' => 'entity', // Can be file, term, user, etc.
  8. 'label' => t('Your label'),
  9. 'configurable' => FALSE, // Doesn't need config form
  10. 'behavior' => array('view_property'), // Uses view access rights
  11. 'triggers' => array('any'), // Works always
  12. ),
  13. );
  14. }

Add action callback where you perform the action:

Get raw version
php
  1. /**
  2.  * Add action callback where you perform the action.
  3.  */
  4. function custom_action_callback_name($entity, $context) {
  5. // Do the magic here.
  6. }