WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] URL Redirect if wp_footer not being called (5 posts)

  1. steckinsights
    Member
    Posted 2 years ago #

    For most people who arrive on this question from a Google search, the advice that you're probably looking for is to add the following to the "additional settings" section of the Contact 7 admin within WordPress dashboard:

    on_sent_ok: "location.replace('http://www.YOURSITE.com');"

    (see this post)

    For others, you can modify the scripts.js file using the instructions from @jcstewart in that same post.

    But for me, this hasn't helped. I, unfortunately, removed the wp_footer tag from my theme because I have pages showing up in a thickbox page; when the thickbox is closed and reloaded, it would load an additional thickbox underneath (very frustrating).

    So, some posts recommended that it was necessary for wp_footer to be loaded in order for the url redirect to work in contact form 7. They said that certain javascript was called, but I'm not sure which necessary javascript is being called by wp_footer.

    How can I get around this?

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

  2. steckinsights
    Member
    Posted 2 years ago #

    No responses yet. Another day of trial & error testing.

    I've discovered that I could call the thickbox feature in another way. In case you're interested, I used this method:

    <!-- Begin Thickbox Initialization -->
    <?php wp_enqueue_style('thickbox'); ?>
    <?php wp_enqueue_script('jquery'); ?>
    <?php wp_enqueue_script('thickbox'); ?>
    <!-- End Thickbox Inititialization -->

    Originally, I had used a function in my functions.php file that called thickbox, but the problem was that the script was being called multiple times when my thickbox opened a page, which caused the thickbox to open multiple times after being closed and reopened.

    Anyway, changing this allowed me to keep wp_footer, which supposedly was what was causing Contact Form 7 and on_sent_ok to not work. But that doesn't seem to have fixed it (though it fixed my thickbox problem and I'm sure is the better way of accomplishing that task).

    So I'm still wondering why Contact Form 7's on_sent_ok method (placed in additional settings within the admin panel) is not redirecting to a URL that I've defined.

    I'm using WordPress version 3.3.1 and Contact Form 7 version 3.0.2.1.

  3. steckinsights
    Member
    Posted 2 years ago #

    I've tried deactivating plugins to see if it was a conflict there, but that doesn't seem to be the case.

    When I fill out the form and click "send" the thickbox disappears and I see the cleared form with text confirming that the form was submitted correctly:

    Your message was sent successfully. Thanks.

    The URL looks like this:

    http://local.mysite.com/?random=1326297393465#wpcf7-f325-p285-o1

    This happens whether or not the form is run through thickbox, so thickbox is not the problem.

  4. steckinsights
    Member
    Posted 2 years ago #

    Yeah, I'm going to be one of those guys... who posts to his own posts. But I figure it's good policy to respond when a solution is found.

    I visited this post: http://www.magecreates.com/why-wont-my-contact-form-7-redirect-code-work/

    Dani Mage had similar symptoms as I, so I tried adding the following code to the end of the message "Sender's message was sent successfully" (replacing the URL with whichever page you desire):

    <script>location.href="http://www.yoursite.com/wp-signup.php"; </script>

    I don't think this was the best way to fix it, and I'd really like to know what is causing the conflict in the first place - my "additional settings" are not being honored. The "on_sent_ok" method is still not working for me. But this hack bypasses that step. It's not seamless and not perfect, but I need to move on.

    If anyone else has a better fix for this, please let us know. I'm sure Dani Mage and I would be happy to hear the answer.

  5. mattmagi
    Member
    Posted 2 years ago #

    I am having this exact same issue, adding in

    <script>location.href="http://www.yoursite.com/wp-signup.php"; </script>

    worked but I would also like to see if anyone has a answer.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic