Skip to content

Instantly share code, notes, and snippets.

@ianpegg
Last active December 8, 2022 14:28
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 ianpegg/f0d207a431ab65a6109818d3efbf089c to your computer and use it in GitHub Desktop.
Save ianpegg/f0d207a431ab65a6109818d3efbf089c to your computer and use it in GitHub Desktop.
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.
*
* @link https://wordpress.org/support/topic/where-to-add-the-x-forwarded-for-code-in-wp-config-php/
*/
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$Arr_http_x_headers = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = $Arr_http_x_headers[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment