Add stuff to the eForm Report mailing
From MODx Wiki
[edit]
Using the eformOnBeforeMailSent event
You need to add some stuff to your eForm report mailing. Let's say you want to add the user's IP address, host, and user agent.
We'll need to use the "eformOnBeforeMailSent" event, and add the fields we want to eForm's fields array.
Create a snippet, I called it "getServer", with a function:
function getServer( &$fields ){ // load SERVER variables into the fields array $fields['remote_addr']=$_SERVER['REMOTE_ADDR']; $fields['remote_host']=$_SERVER['REMOTE_HOST']; $fields['user_agent']=$_SERVER['HTTP_USER_AGENT']; //return success 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:
And here is the result I got:
Contact Input
Name: Test User
Email: test@testing.com
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
[edit]
