Consultant Internet Marketing Expert, SEO Expert & PPC Expert

Including Lead Generation, Conversion Tracking and Sales Coaching

Stay in touch


Or email Vince directly via this...
Contact Form

Recent Articles

Best Reading

Pages

Multilingual

Archive:

Site search

Tags

Categories

Blogroll

Contact Form 7 IP Address, Date/Time and Page URL

Make sure to get FREE 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.

Incoming seo search terms:

Comments

Comment from chandan
Time November 19, 2009 at 11:33 am

nice tips :) was searching this thanks

Comment from vance
Time April 29, 2010 at 3:26 am

I never worked this out did you get to the bottom of it Vince?

Comment from Steve
Time July 20, 2010 at 1:48 pm

Anyone figured this out?

Comment from Nicolas
Time August 18, 2010 at 12:19 pm

Just use the tag [_url]

Comment from Sacramento Wedding Photographer
Time September 14, 2010 at 7:57 pm

Why not just use this, no custom code required!

Users IP: [wpcf7.remote_ip]

Comment from Chris
Time November 9, 2010 at 3:04 pm

Does this code display the user ip address on the form? Or is it just for displaying in the email?

Comment from Vince Samios
Time November 10, 2010 at 7:56 am

Only within the email.

Contact Form 7 has been updated a lot since I wrote this post, but portions are still valid.

Comment from Chris
Time November 11, 2010 at 8:22 pm

Thanks Vince. Do you know if there is a easy way to display the visitors IP address on the form? I’ve been searching the web for a solution but have not see anything.

Write a comment