WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
on_sent_ok Not Working (9 posts)

  1. Adam
    Member
    Posted 1 year ago #

    I have set the on_sent_ok in the additional settings and it's not doing anything. AJAX is working, Javascript is working.

    on_sent_ok: "alert('ok');"

    That doesn't alert anything.

    http://wordpress.org/extend/plugins/contact-form-7/

  2. chipmaga
    Member
    Posted 1 year ago #

    I'm having the same problem. I have my

    <?php wp_head(); ?>
    </head>

    and

    <?php wp_footer(); ?>
    </body>

    in the right place so its loading the right resources I think.

    UPDATE: Okay so I figured out that the form works just fine in the default theme so it has to be something with my custom template. Any thoughts? I'm glad to share my code with anyone who can lend a hand.

  3. pixelslave
    Member
    Posted 1 year ago #

    I struggled with this too. Then I disabled "All in One SEO Pack". Then it worked.

  4. buzztone
    Member
    Posted 1 year ago #

    Posters often don't like to hear it but it's almost always a plugin or javascript conflict on their particular WordPress configuration causing problems like this.

    Like many other popular plugins, CF7 is frequently reported as not working in the WordPress Forums (particularly by users with limited WordPress skill and experience) when the real cause is conflict from another theme or plugin.

  5. Alex P
    Member
    Posted 1 year ago #

    I have the same problem.
    My site http://prontosoccorsolegale.com/go/solosfratti/ cannot execute on_sent_ok functions even disabling all the other plugins.
    It seems the page is reloaded before my function is fired.

    Please help me!

  6. andrelost
    Member
    Posted 1 year ago #

    Hi guys,

    I have the same problem.
    I was trying to set up a thank you page for conversion tracking with this code:

    on_sent_ok: "_gaq.push(['_trackPageview','de/danke']);"

    I tried to change it using the code for event tracking:

    on_sent_ok: "_gaq.push(['_trackEvent', 'Form', 'Form-Submission-DE']);"

    but none of the above code work.
    Then I tried this simple function to show a simple message on correct submit:

    on_sent_ok: "alert('sent');"

    but any message is shown.
    So, I think the problem is the "on_sent_ok()" function.

    Can someone help me?
    Any trick?

  7. andrelost
    Member
    Posted 1 year ago #

    Hello everybody,

    I haven't found any solution to this (I think) bug so I decided to create this javascript that runs a _gaq.push when the "mail-sent-ok" message is shown into the page:

    <script type="text/javascript">
        $(document).ready(function(){
            if($('.wpcf7 form div').hasClass('wpcf7-mail-sent-ok')){
    _gaq.push(['_trackPageview','/destination_tracking_page_url']);
            }
        });
    </script>

    I hope this will help you.

  8. zarkill
    Member
    Posted 11 months ago #

    I had this problem as well, and in my case the conflicting plugin seems to be NextGEN Gallery. When I disable that plugin, the Contact Form 7 redirect works fine - but as long as NextGEN Gallery is enabled, the redirect does not work.

  9. zarkill
    Member
    Posted 11 months ago #

    For what it's worth - I needed to keep NextGEN Gallery active, but when it was active Contact Form 7's Javascripts did not load in the footer.
    So, I manually added the links to the scripts in my theme footer:

    <script type='text/javascript' src='/wp-content/plugins/contact-form-7/includes/js/jquery.form.min.js?ver=3.40.0-2013.08.13'></script>
    <script type='text/javascript'>
    /* <![CDATA[ */
    var _wpcf7 = {"loaderUrl":"\/wp-content\/plugins\/contact-form-7\/images\/ajax-loader.gif","sending":"Sending ..."};
    /* ]]> */
    </script>
    <script type='text/javascript' src='/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=3.5.2'></script>

    I'm sure that's not the best way to do it, but it seems to be the only way I can have both plugins active at the same time, and once I did it this way, the on_sent_ok function started working.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic