I am working with a contact form plugin, written by an external developer several years ago. I want to trigger a file download upon successful completion of the form.
As it stands, I have an
onPost event listener in a separate plugin which fires if the form data is valid and stored in the database correctly:
craft()->on('capture_submissions.onPost', array($this, 'triggerDownload'));
I have tried several things such as redirecting to a controller action:
$url = UrlHelper::getActionUrl('myplugin/whitepaper/download', array('id' => $id)); craft()->request->redirect($url);
Also tried to use sendFile:
This works, however I would like the page to refresh first, displaying a confirmation message and then to trigger the download. As it stands, the download is triggered but the page isn't reloaded so no success message and the form data is still displayed.