Plugin Author
myCred
(@designbymerovingi)
Hi.
Try adding this to your themes functions.php file:
add_filter( 'mycred_affiliate_IP', 'mycred_pro_get_affiliate_true_IP' );
function mycred_pro_get_affiliate_true_IP( $IP ) {
if ( function_exists( 'apache_request_headers' ) )
$headers = apache_request_headers();
else
$headers = $_SERVER;
if ( array_key_exists( 'X-Forwarded-For', $headers ) && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) )
$the_ip = $headers['X-Forwarded-For'];
elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) )
$the_ip = $headers['HTTP_X_FORWARDED_FOR'];
else
$the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
return $the_ip;
}
Note that if your users are using an anonymous proxy, this script will not work since the HTTP_X_FORWARDED_FOR header will not be sent.
Second note, I have not tested this since I do not have access to a proxy to verify that is’s working. Based off Chris Wiegman’s post.