Views Bulk Operations Custom Action Template

Public

You need the two following functions to register and create your custom action. After that, you should be able to enable your custom action in Views Bulk Operations module UI:

</> CopyGet raw version
php
  1. /**
  2.  * Implements hook_action_info().
  3.  */
  4. function MODULE_NAME_action_info() {
  5. return array(
  6. 'module_name_do_some_action' => array(
  7. 'type' => 'node', // Can be file, term, user, etc.
  8. 'label' => t('Do some example action'),
  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. }
  15.  
  16. /**
  17.  * Add action callback where you perform the action.
  18.  */
  19. function module_name_do_some_action($entity, $context) {
  20.  
  21. // Do anything you want with an entity, for example, attach timestamp to title:
  22. $entity->title = $entity->title . time();
  23.  
  24. // Don't forget to save the node
  25. entity_save('node', $entity);
  26. }