0

I work for a company that has multiple sites, but one of them has all of the content. I am using Contact-Form-7 for the little contact forms at the bottom of the page, but what I need is for them to send to different emails depending on which branch of the company they are affiliating with. My main issue is people who wish to contact our Columbian office use the same contact form, because our Columbian website just auto-redirects to the main site. Is there a way to detect if the user got redirected from the Columbian site, before sending the email? Comment if I am unclear. My ideas were to have the home page contain a widget that would make a cookie with the contents of $_SERVER['HTTP_REFERER'], and then make a plugin that would contain a shortcode to look at the cookie and thus change the contact form. Is this the way to go about this?

0

Your themes functions.php is the first file that gets loaded after wordpress, it loads on every page load so you can get a variable with it. You could create a function similar to so and put it in your functions.php of your theme:

global $fromwhere;
if(isset($_GET['from']) and $_GET['from'] == 'columbiansite'){
global $fromwhere;
$fromwhere = 'columbia';
}

you can then edit the contact 7 form plugin like:

global $fromwhere;
if($fromwhere == 'columbia'){
recpient = 'adress@columbiansite.com';
}

You would then need to change the redirect from the columbian site to include ?from=columbiansite at the end of the url. Not an exact code example but a example of the processes that would yield the desired result. There may be a filter for the contact form 7 recipient but im not familiar with the plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.