I would like to modified this code so as to redirect the client to a thank-you page/url once the form has been submitted/email sent. This is in order to insert google adword’s code for conversion tracking.
[php]<?php
/*
Template Name: Contact Form
*/
?>
[/php]
[code]
<div id="content" class="col-full">
<div id="main" class="col-left">
<?php if ( isset($woo_options[ 'woo_breadcrumbs_show' ]) && $woo_options[ 'woo_breadcrumbs_show' ] == 'true' ) { ?>
<div id="breadcrumbs">
<?php woo_breadcrumbs(); ?>
</div><!--/#breadcrumbs -->
<?php } ?>
<div id="contact-page" class="post">
<?php if(isset($emailSent) && $emailSent == true) { ?>
<p class="info"><?php _e( 'Your email was successfully sent.', 'woothemes' ); ?></p>
<?php } else { ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h1 class="title"><?php the_title(); ?></h1>
<div class="entry">
<?php the_content(); ?>
</div>
<?php $geocoords = $woo_options['woo_contactform_map_coords']; ?>
<?php if ($geocoords != '') { ?>
<?php woo_maps_contact_output("geocoords=$geocoords"); ?>
<?php echo do_shortcode( '[hr]' ); ?>
<?php } ?>
<?php if(isset($hasError) || isset($captchaError) ) { ?>
<p class="alert"><?php _e( 'There was an error submitting the form.', 'woothemes' ); ?></p>
<?php } ?>
<?php if ( get_option( 'woo_contactform_email') == '' ) { ?>
<?php echo do_shortcode( '[box type="alert"]'.__( 'E-mail has not been setup properly. Please add your contact e-mail!', 'woothemes' ).'[/box]' ); ?>
<?php } ?>
<form action="<?php the_permalink(); ?>" id="contactForm" method="post">
<ol class="forms">
<li><label for="contactName"><?php _e( 'Name', 'woothemes' ); ?></label>
<input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="txt requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?php echo $nameError;?></span>
<?php } ?>
</li>
<li><label for="email"><?php _e( 'Email', 'woothemes' ); ?></label>
<input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="txt requiredField email" />
<?php if($emailError != '') { ?>
<span class="error"><?php echo $emailError;?></span>
<?php } ?>
</li>
<li class="textarea"><label for="commentsText"><?php _e( 'Message', 'woothemes' ); ?></label>
<textarea name="comments" id="commentsText" rows="20" cols="30" class="requiredField"><?php if(isset($_POST['comments'])) { if(function_exists( 'stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
<?php if($commentError != '') { ?>
<span class="error"><?php echo $commentError;?></span>
<?php } ?>
</li>
<li class="inline"><input type="checkbox" name="sendCopy" id="sendCopy" value="true"<?php if(isset($_POST['sendCopy']) && $_POST['sendCopy'] == true) echo ' checked="checked"'; ?> /><label for="sendCopy"><?php _e( 'Send a copy of this email to yourself', 'woothemes' ); ?></label></li>
<li class="screenReader"><label for="checking" class="screenReader"><?php _e( 'If you want to submit this form, do not enter anything in this field', 'woothemes' ) ?></label><input type="text" name="checking" id="checking" class="screenReader" value="<?php if(isset($_POST['checking'])) echo $_POST['checking'];?>" /></li>
<li class="buttons"><input type="hidden" name="submitted" id="submitted" value="true" /><input class="submit button" type="submit" value="<?php esc_attr_e( 'Submit', 'woothemes' ); ?>" /></li>
</ol>
</form>
<?php endwhile; ?>
<?php endif; ?>
<?php } ?>
</div><!-- /#contact-page -->
</div><!-- /#main -->
<?php get_sidebar(); ?>
</div><!-- /#content -->
<?php get_footer(); ?>[/php]
(Apologies if I have made any mistakes marking out the two different codes)
I think the bit that needs modification is
[code]if(!hasError) {
var formInput = jQuery(this).serialize();
jQuery.post(jQuery(this).attr( 'action'),formInput, function(data){
jQuery( 'form#contactForm').slideUp( "fast", function() {
jQuery(this).before( '<p class="tick"><?php _e( '<strong>Thanks!</strong> Your email was successfully sent.', 'woothemes' ); ?></p>' );
});
});
}
return false;[/code]
perhaps by inserting something like this:
jQuery.post(jQuery(this).attr('action'),formInput, function(data){ window.location.replace('http://www.mysite.com/thankyou.htm'); });
I have tried inserting this in but It was sending multiple emails.
Can anyone please help with the correct code to redirect to a url once form submitted/email sent.
Many thanks in advance