Last active
July 4, 2017 11:23
-
-
Save nciske/7918515 to your computer and use it in GitHub Desktop.
Add IP to WooCommerce email footer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Also tried leaving the function in functions.php and dropping the filter into the template... that didn't seem to do anything either.
Weird. The filter name in the code doesn't match the docs. Fixed it -- grab the new gist and put it in functions.php.
OK, this works perfectly. Here's the screenshot:
https://www.evernote.com/shard/s10/sh/00d74c4c-998e-4164-bacd-28565a753ac5/49b2a2486cdec5777cf6fff82ca655aa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.