2

I currently have a plugin which needs to do things on save and delete entry events. My save entry code is all working perfectly but the onDeleteEntry code doesn't ever fire when I delete an entry.

I have tried using the event both ways mentioned in the documentation

craft()->entries->onDeleteEntry = function(Event $event) {
$entry = $event->params['entry'];
//etc etc
};

and

craft()->on('entries.deleteEntry', function(Event $event) {
$entry = $event->params['entry'];
//etc etc
});

both of these are inside the init function.

Does anyone know if there is a particular way this event needs to be used that differs from the onSaveEntry event, which works fine?

Here's a link to the events reference https://craftcms.com/docs/plugins/hooks-and-events#events

2
  • Were you testing this from the Entry index page by chance?
    – Brad Bell
    Commented Aug 11, 2016 at 23:48
  • @BradBell I'm also having this same issue, when viewing the list of entries, ticking them and deleting them that way. Is there any way around this? (Using latest build of Craft)
    – Jason Mayo
    Commented Nov 10, 2016 at 14:10

1 Answer 1

2

I recently found that if your deleting an entry on the entries list, you need to use the onBeforePerformAction event. Then break this down, like J Thomas states on this -

Get the type of action and the elements(s) that an action is being performed on when listening to elements.onPerformAction?

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.