Download File after submission in Contact Form 7 Wordpress (deprecated on_sent_ok)

為{幸葍}努か 提交于 2019-12-13 07:37:11

问题


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?

来源:https://stackoverflow.com/questions/47346924/download-file-after-submission-in-contact-form-7-wordpress-deprecated-on-sent-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!