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?
1 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!
}
}