Ok, this got my curiosity up, and I figured it out.
You need to use the "eformOnBeforeMailSent" event. Here’s how:
Create a snippet, I called it "getServer":
function getServer( &$fields ){
// remote_addr
$fields['remote_addr']=$_SERVER['REMOTE_ADDR'];
$fields['remote_host']=$_SERVER['REMOTE_HOST'];
$fields['user_agent']=$_SERVER['HTTP_USER_AGENT'];
//return succes
return true;
}
Put the snippet’s tags in your Contact document
before the eForm snippet call.
Add the function to your eForm snippet call:
&eformOnBeforeMailSent=`getServer`
Add the new fields to your Report chunk, just like the other input fields:
<h3>Contact Input</h3>
<strong>Name:</strong> [+name+]<br />
<strong>Email:</strong> [+email+]<br />
<strong>Message:</strong> [+message+]<br />
<strong>IP:</strong> [+remote_addr+]<br />
<strong>Host:</strong> [+remote_host+]<br />
<strong>User Agent:</strong> [+user_agent+]
And here is the result I got:
Contact Input
Name: Test User
Email: [email protected]
Message: This is a test.
IP: 80.178.91.127
Host:
User Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
Since I’m working from a machine behind a NAT’d router via a dynamic IP, it’s not at all surprising that the REMOTE_HOST isn’t being passed.
See the documentation at
http://wiki.modxcms.com/index.php/EForm for more about the EForm events and how to make use of them.