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

  • Were you testing this from the Entry index page by chance? – Brad Bell Aug 11 '16 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 Nov 10 '16 at 14:10
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?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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