Last active
August 5, 2019 09:50
-
-
Save vhsu/aad62aafd2f782e826f8c0e3589b5440 to your computer and use it in GitHub Desktop.
Override $_SERVER['REMOTE_ADDR'] for Wordpress with Contact form 7 [_remote_ip] shortcode and Cloudflare
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
// Override $_SERVER['REMOTE_ADDR'] on Wordpress to retrieve the client ip for cloudflare users | |
// This will also correct the [_remote_ip] shortcode with contact form 7 ( wpcf7 ) or any other plugin using $_SERVER['REMOTE_ADDR'] | |
// Simply add the following code in the wp_config.php file and you're done. | |
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { | |
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment