<p>You can create a <a href="http://pluginfactory.io" rel="nofollow">simple plugin</a> that listens to the <a href="https://craftcms.com/docs/plugins/events-reference#entries-onDeleteEntry" rel="nofollow">onDeleteEntry</a> <a href="https://craftcms.com/docs/plugins/hooks-and-events#events" rel="nofollow">event</a>.</p>

<p>There is an <code>entry</code> parameter passed into that event that is the <a href="https://craftcms.com/docs/templating/entrymodel" rel="nofollow">EntryModel</a> object that represents the entry that was just deleted.</p>

CC BY-SA 3.0
2016-09-22T03:00:24.833Z
craft()->on('entries.onDeleteEntry', function(Event $event) { Craft::log(" HELLO delete on delete ######\n\n", LogLevel::Info, true); });  I created a plugin and added this to the init function, but it isnt being called. Do you know why it might be? Also, I am using  craft 2.6.
user2997606
CC BY-SA 3.0
2016-09-22T04:03:06.373Z
@user2997606 Just to check, did you remember to install your plugin via Settings -> Plugins?
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-09-22T04:10:01.077Z
@mats-mikkel-rummelhoff Yeah, I did that.
user2997606
CC BY-SA 3.0
2016-09-22T23:10:38.220Z
Hard to say without seeing your plugin code. Maybe post a new question with the relevant code in it?
Brad Bell
CC BY-SA 3.0
2016-09-22T00:20:43.577Z
2016-09-22T00:20:43.577Z
Brad Bell
<p>Is there a way to call a custom function after an entry is deleted successfully?</p>

<p>If there isn't, is there a record of the deleted record stored anywhere?</p>

<p>Currently, I am thinking of editing the <code>actionPerformAction</code> in <code>elementIndexController</code>, but I don't want to edit the application files, so if there is another method I would prefer that.</p>

<plugin-development>
Calling a plugin function after an entry is deleted?
# Calling a plugin function after an entry is deleted?

(Asked by: username_0 on 2016-09-21)

Is there a way to call a custom function after an entry is deleted successfully?

If there isn't, is there a record of the deleted record stored anywhere?

Currently, I am thinking of editing the `actionPerformAction` in `elementIndexController`, but I don't want to edit the application files, so if there is another method I would prefer that.

**Tags:** plugin-development


---

## 1 answers

### Answer by username_1 on 2016-09-22. Score: 2 | Accepted answer

You can create a [simple plugin](http://pluginfactory.io) that listens to the [onDeleteEntry](https://craftcms.com/docs/plugins/events-reference#entries-onDeleteEntry) [event](https://craftcms.com/docs/plugins/hooks-and-events#events).

There is an `entry` parameter passed into that event that is the [EntryModel](https://craftcms.com/docs/templating/entrymodel) object that represents the entry that was just deleted.

> **Comments:**
> **username_0**: craft()->on('entries.onDeleteEntry', function(Event $event) { Craft::log(" HELLO delete on delete ######\n\n", LogLevel::Info, true); });  I created a plugin and added this to the init function, but it isnt being called. Do you know why it might be? Also, I am using  craft 2.6.  
> **username_2**: @username_0 Just to check, did you remember to install your plugin via Settings -> Plugins?  
> **username_0**: @mats-mikkel-rummelhoff Yeah, I did that.  
> **username_1**: Hard to say without seeing your plugin code. Maybe post a new question with the relevant code in it?  

---

