1

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?

4

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!
    }
}
| 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.