Title: ON_SENT_OK code deprecated
Last modified: September 28, 2017

---

# ON_SENT_OK code deprecated

 *  [maxidg](https://wordpress.org/support/users/maxidg/)
 * (@maxidg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/)
 * hi there a question … i read about that on_sent_ok will be deprecated … and i
   can use a script like this:
 * <script>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) { location
   = ‘[http://example.com/&#8217](http://example.com/&#8217);; }, false ); </script
   >
 * and i put this code in my admin theme panel in extra javascript … and working..
 * but … with code on_sent_ok in each of my form i sent my customer to different
   thank you page … now with the script is not possible?
 * suggestions?
 * best regards

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [aozcorap](https://wordpress.org/support/users/aozcorap/)
 * (@aozcorap)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9539669)
 * Hi,
 * I have following code in the addtional setting of Contact Form
 * on_sent_ok: “location = ‘[http://www.exampel.com&#8217](http://www.exampel.com&#8217);;”
 * and would like to know, how does the code look like in function.php.
 * Please notice, that I am not a developer.
 * Thanks
 *  Thread Starter [maxidg](https://wordpress.org/support/users/maxidg/)
 * (@maxidg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9539849)
 * Hi [@aozcorap](https://wordpress.org/support/users/aozcorap/),
 * me too, but that code at the end of 2017 will be deprecated … so you must change
   the rule … i mean for me i put this code:
    <script> document.addEventListener(‘
   wpcf7mailsent’, function( event ) { location = ‘http://example.com/’; }, false);
   </script> in my admin theme panel extra java script and working well … but my
   question is another.
 * I hope that can help you.
 *  [aozcorap](https://wordpress.org/support/users/aozcorap/)
 * (@aozcorap)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9539867)
 * where exactly did you put it in the admin theme panel?
 *  Thread Starter [maxidg](https://wordpress.org/support/users/maxidg/)
 * (@maxidg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9540146)
 * it’s depend which theme you have? is a free theme or commercial?
 *  [aozcorap](https://wordpress.org/support/users/aozcorap/)
 * (@aozcorap)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9540149)
 * it’s a commercial one.
 * Elegant Themes
 *  [aozcorap](https://wordpress.org/support/users/aozcorap/)
 * (@aozcorap)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9540206)
 * I added in the <head> following code:
 * <!– Contact Form Code redirect to URL after Submit –>
    <script> document.addEventListener(‘
   wpcf7mailsent’, function( event ) { location = ‘[http://www.example.com&#8217](http://www.example.com&#8217);;},
   false ); </script> <!– END: Contact Form Code redirect to URL after Submit –>
 *  Thread Starter [maxidg](https://wordpress.org/support/users/maxidg/)
 * (@maxidg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9540280)
 * ok in head of which php page? becarefull if you put the code in the function.
   php when u update the theme you lost the code …
    so i think is better to look
   your theme admin panel and search for custom css and custom java script and u
   can put there the code … 🙂
 * see u
 *  [aozcorap](https://wordpress.org/support/users/aozcorap/)
 * (@aozcorap)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9540470)
 * This is very strange to be honest.
 * I added the code
    <script>document.addEventListener( ‘wpcf7mailsent’, function(
   event ) {location = ‘[http://www.personal-training-mittelhessen.de/confirm&#8217](http://www.personal-training-mittelhessen.de/confirm&#8217);;},
   false );</script>
 * in the theme admin panel where I can insert scripts in the head of the page. 
   This area contains also the facebook pixel code.
 * But if I add the code just below the facebook pixel code, it does not work.
 *  Thread Starter [maxidg](https://wordpress.org/support/users/maxidg/)
 * (@maxidg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9540503)
 * first of all i hope that you write like in my example .. i mean in different 
   line … second … if not work try to put before ..
 * hmhmh … 🙂
 *  [aozcorap](https://wordpress.org/support/users/aozcorap/)
 * (@aozcorap)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9540555)
 * Yes, the code is as following
 * <script>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) { location
   = ‘http://www.example.com’; }, false ); </script>
 * and I added it right before the Facebook Pixel code, but still does not work 
   🙁
 *  Thread Starter [maxidg](https://wordpress.org/support/users/maxidg/)
 * (@maxidg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9541443)
 * for me this plugin resolve!!!
 * [https://wordpress.org/plugins/contact-form-7-success-page-redirects/](https://wordpress.org/plugins/contact-form-7-success-page-redirects/)

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘ON_SENT_OK code deprecated’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [on sent ok](https://wordpress.org/support/topic-tag/on-sent-ok/)

 * 11 replies
 * 2 participants
 * Last reply from: [maxidg](https://wordpress.org/support/users/maxidg/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/on_sent_ok-code-deprecated/#post-9541443)
 * Status: not resolved