Add source url to your Contact Form 7

Want to figure out where your customers are sending you an email from Contact Form 7 from? If you keep a contact form in a WordPress sidebar, you get it, but is there any pattern? Where might I be able to put a little additional advertising to get a little more bang?

Toss this into your function.php file for your theme

/**
** A base module for [sourceurl] in Contact Form 7
**/

/* Shortcode handler */

wpcf7_add_shortcode('sourceurl', 'wpcf7_sourceurl_shortcode_handler', true);

function wpcf7_sourceurl_shortcode_handler($tag) {
	if (!is_array($tag)) return '';

	$name = $tag['name'];
	if (empty($name)) return '';

	$html = '';
	return $html;
}

Then toss this into your Contact Form – I usually put mine next to the bot check to keep things clean.

[sourceurl thesource]

And then just include it into your mail message body with this (or some derivative…

SourceURL: [thesource]

Author: Eric Erickson

Share This Post On

Submit a Comment

Your email address will not be published.