Skip to content

Instantly share code, notes, and snippets.

@nciske
Last active July 4, 2017 11:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nciske/7918515 to your computer and use it in GitHub Desktop.
Save nciske/7918515 to your computer and use it in GitHub Desktop.
Add IP to WooCommerce email footer
<?php
add_filter('woocommerce_email_footer_text','add_ip_to_email_footer', 10, 1);
function add_ip_to_email_footer( $footer ){
return $footer . ' IP: ' . getRealIPAddress();
}
function getRealIPAddress(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
$remote_ip =$_SERVER['HTTP_CLIENT_IP'];
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$remote_ip =$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$remote_ip =$_SERVER['REMOTE_ADDR'];
}
return $remote_ip;
}
@mclanecreative
Copy link

OK, I give up. I tried putting this in function.php and in the actual woocommerce/emails/customer-new-account.php file... and it doesn't display anything.

@mclanecreative
Copy link

Also tried leaving the function in functions.php and dropping the filter into the template... that didn't seem to do anything either.

@nciske
Copy link
Author

nciske commented Dec 11, 2013

Weird. The filter name in the code doesn't match the docs. Fixed it -- grab the new gist and put it in functions.php.

@mclanecreative
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment