-
Author
-
June 15, 2017 at 03:41 #164316kjcarleoParticipant
Hello I am trying to do a rediect with the following code:
<
script
>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'http://embassymarine.org/join-us-next=-steps';
}, false );
</
script
>
The following article mentions (near the bottom) I should “Embed this snippet into your theme’s template file.“, what file would that be? And do I need the <script> handlers?The Article: https://contactform7.com/redirecting-to-another-url-after-submissions/KevinJune 16, 2017 at 00:52 #164387LauraModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! ?Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
June 19, 2017 at 16:35 #164625RaduModeratorHi,
Just add it to wp-admin -> theme options -> general settings -> JavaScript code including the script tags
That’s itCheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 19, 2017 at 17:32 #164641kjcarleoParticipantI tried it with and without the <script> tags, but no redirect yet. Cleared the cache on the server and my internet cache as well. Any ideas?
June 21, 2017 at 18:05 #164859RaduModeratorHi,
The Js snippet cannot be found in your source page
Make sure you have added that…
Paste the snippet again
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 21, 2017 at 19:10 #164870kjcarleoParticipantI see the snippet now, but it is still not working 🙁
Attachments:
You must be logged in to view attached files.June 23, 2017 at 19:22 #165029RaduModeratorI see there it’s an IF condition,
Try to put the snippet as authr has provided as example
COPY CODE<script> document.addEventListener( 'wpcf7mailsent', function( event ) { location = 'http://example.com/'; }, false ); </script>
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 23, 2017 at 19:41 #165036kjcarleoParticipantYes, but I only want it to occur when this particular form is used, hence the “if” statement as referred at the bottom of this page:
June 27, 2017 at 15:43 #165384RaduModeratorHi,
Just tested and it works,
If you will add a form to a new page or existing one the alert it’s shown
Inside the theme options JS I have this
COPY CODE<script> jQuery(document).ready(function() { document.addEventListener( 'wpcf7submit', function( event ) { if ( '10032' == event.detail.contactFormId ) { alert( "The contact form ID is 10032." ); // do something productive } }, false ); }); </script>
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 9, 2017 at 16:29 #166795kjcarleoParticipantThat’s great, but what about making it redirect to another page, that code didn’t seem to work.
July 11, 2017 at 16:40 #167027RaduModeratorHi,
That code will work only in pages where the contact form shortcode it’s placed like contact one, where the code doesn’t work?
Are you want to use this in combo with floating contact from the kleo theme ? or how ?
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 15, 2017 at 21:50 #167542kjcarleoParticipantI just want to use it on the following form: https://embassymarine.org/join-us/ [contact-form-7 id=”10326″ title=”Application for Membership”]
I want it to redirect to another page after the form is submitted.
Kevin
July 18, 2017 at 16:07 #167816RaduModeratorHi,
Just add this code to JavaScript code from wp-admin -> theme options -> general options
COPY CODE<script> jQuery(document).ready(function() { document.addEventListener( 'wpcf7submit', function( event ) { if ( '10032' == event.detail.contactFormId ) { window.location.href="http://google.com"; // do something productive } }, false ); }); </script>
Replace 10032 with the form id, it redirects after submit it works I’ve tested
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 19, 2017 at 07:36 #167910kjcarleoParticipantI added the above code, but it is still not redirecting – please help.
Here is the code I added to the Quick CSS Section under wp-admin -> theme options -> general options
COPY CODE<script> jQuery(document).ready(function() { document.addEventListener( 'wpcf7submit', function( event ) { if ( '10326' == event.detail.contactFormId ) { window.location.href="https://embassymarine.org/join-us-next-steps/"; // do something productive } }, false ); }); </script>
July 20, 2017 at 16:05 #168068RaduModeratorHi,
That’s ODD, I don’t know what advice to give you at this moment, provide admin credentials.
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 24, 2017 at 17:08 #168427RaduModeratorHi
Let me know when the site it’s reachable
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 25, 2017 at 22:10 #168561RaduModeratorHi,
IT works, check : https://embassymarine.org/join-us/
I’ve added the code in header content
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJanuary 9, 2019 at 00:38 #216213kjcarleoParticipantGuys I noticed it has been working this whole time, however even if there is an error on the form or filezise of attachment it still redirects and the form is never sent. Is there any way to only redirect if there are no errors?
KJ
January 9, 2019 at 19:42 #216258RaduModeratorHi,
For further development you will need to hire a dev to make the conditions in every case you need for your business.
I recommend you to ask for a solution on contact form 7 forum since this question it’s more related to their product not ours.
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJanuary 10, 2019 at 16:46 #216296RaduModeratorOk
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Bugs & Issues’ is closed to new topics and replies.