I want the user to download a PDF file after submitting a simple Contact Form 7 in Wordpress.
I see that the on_sent_ok is deprecated and won't be allowed by the end of 2017 and should be replaced by DOM Events.
I am having issues achieving this with the following code:
.htaccess file:
<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
functions.php:
function mycustom_wp_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '1497' == event.detail.contactFormId ) {
location( 'http://stagingarea2.craigsapsford.com/wpcontent/uploads/dlm_uploads/2017/11/Test-Document.pdf' );
}
}, false );
</script>
<?php
}
Where am i going wrong with this current setup?