I have a form that redirects and opens a "thank you" page on submission, but I would like no one to have access to this page by URL. This page should be accessible from the redirection of the form. The problem is that I tried to do it from .htaccess
, but it does not work.
Current URL: mySite.com/thank-you
I would like to mask it as: mySite.com/
I used this code in function.php:
/**
* Form ---> Thank you page
*
*/
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '6881' == event.detail.contactFormId ) { // Sends sumissions on form idform to the thank you page
location = '/thank-you/';
} else { // Sends submissions on all unaccounted for forms to the third thank you page
// Do nothing
}
}, false );
</script>
<?php
}
I don't know how to make it possible. Can someone help me please?