Forked from vhsu/wpcf7-ip-shortcode-wordpress-cloudflare.php
Created
January 29, 2018 19:23
-
-
Save minichiello/eaaa288e96266c1a74520c6153264119 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 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