tags:

views:

149

answers:

1

I have several sites that I want to link back to the main site which hosts the contact form (using contact form 7).

I would like to capture the request parameter "site-url" on incoming links to the contact form.

Then when the user submits the form, I would like to redirect them back to the site specified in the site-url.

Any ideas if this is possible with contact form 7?

I would also like to add a special field in the contact form which would insert the site-url into the email that i get so that I know which site they were referred from.

A: 

Contact Form Page

<?php
session_start();

$redirect = $_GET['site-url'];
$_SESSION['redirect'] = $redirect;

POST Contact Form Page

<?php
session_start();

$redirect = $_SESSION['redirect'];

mail('[email protected]','Contact Form',$redirect);

header("Location: {$redirect}");
exit();
Brant
Looks great Brant, I'm off to test it now. Thanks for the quick help. Have you had to do this before?
Scott B
Do this all the time. I usually write this into some kind of method that I can call anytime I want to redirect. I also use $_SERVER['REQUEST_URI'] to automatically set the $redirect variable.
Brant
I guess I meant specifically on "contact form 7"
Scott B
Brant, I believe your code will work, but can you help me understand how to integrate it into contact form 7? For example, there is no separation between a "form page" and a "POST" page. The contact script appears to all be contained in a single php file, wp-contact-form-7.php
Scott B
I went and read the documentation and the code. Looks like they're using regular expressions to handle everything. I would suggest trying a few different contact forms. But if you're determined try this fix for the hidden fields. http://www.seodenver.com/contact-form-7-hidden-fields/
Brant
Brant, which contact form do you use that works with your answer? I'd just as soon try that than try to hack into contact form 7 :)
Scott B
@Scott Here's one that may suffice. http://www.dagondesign.com/articles/secure-form-mailer-plugin-for-wordpress/#form
Brant