Contact Form 7 IP Address, Date/Time and Page URL
Make sure to get FREE DIY SEO link packages Vince's Links
In a previous post I wrote about adding an IP address field into Contact Form 7 1.9.3
Since then there have been major updates to Contact Form 7, which renders the initial how-to inaccurate.
Luckily - in recent updates Contact Form 7 has added a new tag [wpcf7.remote_ip] which replaces the Adding IP part of my tutorial.
Two functions which haven’t been added and which now no-longer work with my old how-to are adding date and time to Contact Form 7, and adding the Source Page into Contact Form 7.
The function for adding the source page is still the same:
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER["SERVER_PORT"] != “80″) {
$pageURL .= $_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
But this time, add it to the bottom of the includes/classes.php file, before the very last “?>”
Next, in the same file (includes/classes.php) search for this line:
$enctype = apply_filters( 'wpcf7_form_enctype', '' );
Directly below this line, add the following code:
$curpageurl = curpageurl();
date_default_timezone_set('GMT');
$timedate = date('l jS \of F Y h:i:s A');
Now search for this line:
. esc_attr( WPCF7_VERSION ) . '" />' . "\n";
Below which you need to add a line and insert the following code:
$form .= '<input type="hidden" name="time-date" value="' . $timedate . '" />';
$form .= '<input type="hidden" name="page-url" value="' . $curpageurl . '" />';
The next step - actually sending those values with the form, is still a mystery…
If you check the form code after making these changes you can see the source page and time/date variables being displayed… but they don’t send with the email…
If you’ve worked it out, please comment below.
Tags: Contact Form 7, IP Address, wordpress contact form, Wordpress Plugin
SEO Guide for 2010
nice tips
was searching this thanks
I never worked this out did you get to the bottom of it Vince?
Anyone figured this out?
Just use the tag [_url]