6

In a plugin init function I'm listening to entries.saveEntry and entries.deleteEntry. This works perfectly if I'm editing entries from their detail view. If I 'bulk' change or delete entries, these events are not fired. I saw in the SetStatusElementAction class an event called onSetStatus is triggered but how can I listen to it? The same goes with the delete action.

Somehow the following doesn't get triggered for me:

craft()->on('entries.setStatus', function($event){ dd($event); });

What am I missing here?

1
  • Typically, we'd close something like this as a "bug report". But since this is a long-standing known bug, we'll keep the thread open until it eventually gets fixed.
    – Lindsey D
    Commented Apr 11, 2016 at 16:46

2 Answers 2

2

Unfortunately, this is a known bug in Craft. Bulk actions do not trigger their respective events.

I'm not sure when (if?) a solution will appear. I'm guessing that it won't be fixed in the 2.x branch, since this bug has existed for quite awhile now. With any luck, it'll be fixed when Craft 3 launches.

1

Lindsey's answer is correct, but as a workaround, you can listen to the onBeforePerformAction or onPerformAction events, check to see if the action parameter to see if it's the action you're interested in and perform your logic as necessary.

4
  • How do you get the ID(s) of the element(s) that the action is being performed on?
    – jthomas
    Commented Sep 16, 2016 at 18:24
  • @jthomas Can you post that as a new question and I'll answer? Probably helpful to other people, too.
    – Brad Bell
    Commented Sep 16, 2016 at 22:47
  • Yep, I'd be happy to.
    – jthomas
    Commented Sep 16, 2016 at 23:25
  • 2
    Question and answer here: craftcms.stackexchange.com/questions/16831/…
    – jthomas
    Commented Sep 17, 2016 at 14:42

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.