Created
March 12, 2014 15:51
-
-
Save ryanjbonnell/9509696 to your computer and use it in GitHub Desktop.
WordPress Config: Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
This file contains 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
// Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address | |
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { | |
$http_x_headers = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ); | |
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0]; | |
} |
Thanks
Works perfectly with Cloudflare! Thank you
Thanks. Working with Ithemes Security plugin behind proxy.
For anyone hosting their WordPress blog on Heroku: the left-most IP is not guaranteed to be the client's real IP, while the right-most one should be, as per this answer .
super grateful 😀👍
yes! Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this tip. It's exactly what I was looking for, Ryan.
Any chance this option will become available as a plugin, so regular Wordpress users don't have to touch the code?
@luisan00, mira esto :)