I've recently coded a few Drupal\x\Plugin\Action classes that respond nicely to my VBO (now bulk actions?) in Drupal 8. Now I'd like to implement a hook, or whatever is required, to take action when all the entities in a selected action have been processed...essentially a VBO post-process hook like we had with hook_views_bulk_operations_finish in Drupal 6. Where and how can I implement that?

I see no obvious hook in D8 to do this, and unfortunately, I've been unable to get Rules to work in D8 (still really confused by Rules and Actions configuration) so I really don't want to go down that path if I don't have to, yet.

1 Answer 1


This is how I tackled this scenario in D7.

In my custom VBO code I did a variable_set() and then I use hook_views_pre_render (note that the D8 hook params changed, so don't copy the hook from my code below) and did a variable_get(), if it was not empty, then do your action.

 * Implements hook_views_pre_render().

function bulk_mail_hauliers_auto_emailing_views_pre_render(&$view) {
// check the view name
if ($view->name == 'hauliers_auto_emailing') {

    $store_all_in_one_en = variable_get('bulk_mail_hauliers_auto_emailing_all_in_one_en', 0); 

    // check that variable_get is not empty, which means VBO ran.
    if ($store_all_in_one_en != 0) {


      // delete the variable



So you can basically do this in D8, except use the D8 equivalent of variable_set,get,del.

  • 1
    This was perhaps not the answer I was expecting, but it does indeed work in Drupal 8. I implemented it in D8 around the user.private_tempstore service like so: $tempstore = \Drupal::service('user.private_tempstore')->get('buffer'); $tempstore->set(('buffered_text'), $text); $tempstore = Drupal::service('user.private_tempstore')->get('buffer'); if ($text = $tempstore->get('buffered_text')) {...} May 14, 2017 at 14:03
  • I haven't tried your code, but the concept is a brilliant solution. Thanks.
    – jhchnc
    Nov 29, 2018 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.