I'm currently working on a plugin that sends an email before the Guest Entries Plugin saves the entry. But one of the fields is an asset field and the file may be renamed when uploaded so I need to switch this up so the email being sent after the entry is saved. I tried creating an onEntrySave event in the Guest Entries plugin by doing the following.
Added to GuestEntriesService.php:
/**
* Fires an 'onSaveEntry' event.
*
* @param GuestEntriesEvent $event
*
* @return null
*/
public function onSaveEntry(GuestEntriesEvent $event)
{
$this->raiseEvent('onSaveEntry', $event);
}
In GuestEntriesController.php I've added
$this->onSaveEntry(new GuestEntriesEvent($this, array('entry'=> $entry,'isNewEntry' => true)));
to the section of the code where the entry is saved.
if (craft()->entries->saveEntry($entry))
{
$this->onSaveEntry(new GuestEntriesEvent($this, array('entry'=> $entry,'isNewEntry' => true)));
$this->_returnSuccess($entry);
}
But this is where I've gone wrong as I get the error:
Craft\GuestEntriesController and its behaviors do not have a method or closure named "onSaveEntry".
How do I go about modifying the plugin to trigger an onSaveEntry event?