Skip to content

Instantly share code, notes, and snippets.

@ochebotar
Forked from ryanjbonnell/wp-config.php
Created May 6, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochebotar/090d0297e5ea72840055a9a3605002f4 to your computer and use it in GitHub Desktop.
Save ochebotar/090d0297e5ea72840055a9a3605002f4 to your computer and use it in GitHub Desktop.
WordPress Config: Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
// 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];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment