Old code:
on_sent_ok: “location.replace(‘/equity-release-calculations/?cli-nam=’+document.getElementById(“firstname”).value+’&age=’+document.getElementById(“age”).value+’&prop-val=’+document.getElementById(“propertyvalue”).value);”
DOM created in Functions.php:
* DOM event method for passing demo CF7 data */
add_action( ‘wp_footer’, ‘mycustom_wp_footer’ );
function mycustom_wp_footer() {
?>
<script type=”text/javascript”>
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
location.replace(‘/equity-release-calculations/?cli-nam=’+document.getElementById(“firstname”).value+’&age=’+document.getElementById(“age”).value+’&prop-val=’+document.getElementById(“propertyvalue”).value);
}, false );
</script>
<?php
}
Help would be apprieciated
Regards
A
on_sent_ok: “jQuery.ajax({ type : ‘POST’, url : ‘https://office.ourwebsite.com/crm/createCNTOP.php’,data : jQuery(‘.wpcf7-form.sent’).serialize(),success:function(data) { location=’https://ourwebsite.com/thankyou/’ ; } });”
]]>on_sent_ok: “location = /uploads/2018/02/Wrenbury-Hall-Wedding-Brochure-2018.pdf’;”
I don’t have any access to any php files to make these changes so need to know how to get around this, otherwise I cannot update the plugin as it stops supporting it.
]]>Since some days I have a problem with my formular tracking using Contact Form 7. CF7 tells me that “on_sent_ok” is deprecated and that I have to replace it with DOM Events. I have no idea – does anybody have?
Here is the link to the helping page of Contact Form 7: https://contactform7.com/2017/06/07/on-sent-ok-is-deprecated/
Thanks in advance!
Niklas
]]>Someone has the same problem or can help me? I would like to find a easy alternative code.
]]>As of now, I have to write PHP to create a script variable that loops through all the CF7 contact forms and returns on array with CF7ID and CF7 Form name. That’s a little messy.
Before you remove on_sent_ok functionality, would it be possible to add the contact form name or title to the event object that is returned with each dom event, the same way we can access the form id (event.detail.contactFormId)?
It might also be helpful if you could also figure out a way to return a redirect url in the same object. Maybe a new additional field called ‘redirect_to’ or something like that.
CF7 is one of the most used contact form solutions and I really want to thank you for all your work over the years. But, as it stands now, I stand to lose event tracking on dozens of client websites unless I whip up a custom PHP solution to get the form name and redirect URL and now have to update all the forms on all my client sites since it seems to indicate that this functionality will stop working in early 2018. Please keep backwards compatibility if you can, at least.
]]>I am not a programmer, many of us on here are not programmers. The new DOM Event option is not user friendly for us non programmers. PLEASE implement a way in your plugin to allow us to redirect.
The thing is in my particular case, I need to be able to redirect outside of my site. I run art classes, and people will sign up and then will be redirected to my SQUARE page for payment. This is pretty vital for me and now that ON_SENT_OK is no longer working, I’m scrambling to fix it.
I found your page (https://contactform7.com/redirecting-to-another-url-after-submissions/) with the DOM equivalent, but to me this is a one size fits all solution and doesn’t fit my needs. I have many forms, and each form goes to a different location, some externally, others not, and to insert this code in the template file looks like it will redirect every single form to the same place, which is not what I need or what. This code needs to work like ON_SENT_OK and give us the option to redirect anywhere we want on a form by form basis.
PLEASE come up with an easier solution to this. ON_SENT_OK was brilliant for us non programmers, and this new change to it is not easy or user friendly.
Thanks for reading.
E
If it’s completely independent from that, then great!
]]>first of all i just wanted to thank you for developing such a nice plugin. I didn’t have any problems with it since few years.
I am just concerned with upcoming depreciation of function ‘on_sent_ok’. I was using it on lot of projects to push some GA/FB events and trigger some DOM manipulation for confirmation messages etc.
I saw that in 4.9 you are throwing out depreciation notice so i guess it is coming to an end.
IMHO functions declared can’t be easily moved to DOM, it requires extra time to work on it. Also having on_sent_ok in dashboard is really helpfull solution for non-programmers to chnage some behaviors.
My question is if could you add some filter/option to support this as legacy feature in next releases just by adding some non-default enabled option? I am aware of security-risk but it would be great to not be forced to convert lot of logic on site.
So we could assume that with upcoming update you will disable it entirely and it will stop to work. But it would be great to be able to enable it in wp-config or functions.php like this:
define ('WPCF7_on_sent_ok', true );
I guess it’s better to not drop future updates just in favor to keep this option, and just be aware of potential security issues.
Thanks,
Maciej