top of page

Redirect Contact Form 7 to third party site

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Feb 26, 2021
  • 1 min read

The following code is used for redirecting to a third party site



add_action( 'wp_footer', 'ca_redirect_form',9999); 
function ca_redirect_form() {
    $thankyoulink = get_field('redirect_url', 'option');
	$wpcf7        = WPCF7_ContactForm::get_current();
	$form_id      = $wpcf7->id;

?>
	<script>
	document.addEventListener( 'wpcf7mailsent', function( event ) {

		setCookie('user_cookied','yes',3650);
		console.log('user cookied');

		var inputs = event.detail.inputs;

		if(event.detail.contactFormId == '21653'){

				jQuery('#whitepapercookie').hide();
				var sharpurl 		 = jQuery('#sharpwhitepaperurl').val();
				window.location.href = sharpurl;
		}else{


			var append = '';

			if ( '18024' == event.detail.contactFormId ) { 
				for ( var i = 0; i < inputs.length; i++ ) {
					if ( 'email-id' == inputs[i].name ) {
						email = inputs[i].value;
					}
					if ( 'first-name' == inputs[i].name ) {
						fname = inputs[i].value;
					}
					if ( 'last-name' == inputs[i].name ) {
						lname = inputs[i].value;
					}
					if ( 'company-name' == inputs[i].name ) {
						comp = inputs[i].value;
					}
					if ( 'text-phone' == inputs[i].name ) {
						phone = inputs[i].value;
					}
				}
				append = '&email=' + email + '&firstname=' + fname + '&lastname=' + lname + '&company=' + comp + '&phone=' + phone;
		    }

		    if( '20619' == == event.detail.contactFormId ){

		    	if ( 'Email' == inputs[i].name ) {
						email = inputs[i].value;
				}

		    	append = '&email=' + email;
		    }

		    



	      	window.location.href = '<?php echo $thankyoulink; ?>'+append;
		}
	}, false );
	</script>

<?php 

} 


 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page