<p>You would compare against the entry's section / entry type in a conditional. The entry modal is available from the event params <code>$event-&gt;params['entry']</code>.</p>

<pre><code>craft()-&gt;on('entries.onSaveEntry', function(Event $event)
{
    $entry = $event-&gt;params['entry'];

    if($entry-&gt;section['handle'] == 'mySection' &amp;&amp; $entry-&gt;type['handle'] == 'myEntryType')
    {
        // Execute for mySection / myEntryType entries only!
    }
}
</code></pre>

CC BY-SA 3.0
2015-04-17T11:48:05.650Z
2015-04-17T11:48:05.650Z
carlcs
<p>Using the entries.onSaveEntry event, how would I ensure it's only applied to entries in a particular section? Or is there a way to make a distinction between an entry saved from the control panel and an entry created on a front-end form?</p>

<plugin-development>
Calling onSaveEntry event only for one section
# Calling onSaveEntry event only for one section

(Asked by: username_0 on 2015-04-17)

Using the entries.onSaveEntry event, how would I ensure it's only applied to entries in a particular section? Or is there a way to make a distinction between an entry saved from the control panel and an entry created on a front-end form?

**Tags:** plugin-development

---

## 1 answers

### Answer by username_1 on 2015-04-17. Score: 4 | Accepted answer

You would compare against the entry's section / entry type in a conditional. The entry modal is available from the event params $event->params['entry'].
craft()->on('entries.onSaveEntry', function(Event $event)
{
    $entry = $event->params['entry'];

    if($entry->section['handle'] == 'mySection' && $entry->type['handle'] == 'myEntryType')
    {
        // Execute for mySection / myEntryType entries only!
    }
}


---

