• Hi,

    I have an issue with your plugin when I am using Cloudflare as a CDN.
    The GeoIP detection then does not work anymore and nothing is displayed.

    Cloudflare mention they offert IP Geolocation but I never succeeded to implement their function qith your plugin.

    I believe many people around are in the same situation.

    Cloudflare mentions they have this function :

    $country_code = $_SERVER[“HTTP_CF_IPCOUNTRY”]; // to access in PHP

    But I do not know what to do with it, ie where to implement it in your plugin to retrieve visitor IP properly.

    Thanks for any answer and jkudos for the nice plugin.

    https://wordpress.org/plugins/wp-insert/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Namith Jawahar

    (@namithjawahar)

    Try editing the function as follows from

    function wp_insert_countries_init() {
    	global $wpInsertGeoLocation;
    	try {
    		if(!class_exists('GeoIP')) {
    			include(WP_INSERT_DIR.'/includes/common/geoip/geoip.inc');
    		}
    		if(function_exists('geoip_open') && function_exists('mb_internal_encoding')) {
    			$geoIP = geoip_open(WP_INSERT_DIR.'/includes/common/geoip/GeoIP.dat', GEOIP_MEMORY_CACHE);
    			$wpInsertGeoLocation = geoip_country_code_by_addr($geoIP, $_SERVER["REMOTE_ADDR"]);
    			geoip_close($geoIP);
    		} else {
    			add_action('admin_notices', 'wp_insert_countries_error_notice', 0);
    		}
    	} catch(Exception $e) {
    		add_action('admin_notices', 'wp_insert_countries_error_notice', 0);
    	}
    }

    TO

    function wp_insert_countries_init() {
    	global $wpInsertGeoLocation;
    	$wpInsertGeoLocation = $_SERVER["HTTP_CF_IPCOUNTRY"];
    }

    The function is located in wp-insert/includes/common/countries.php

    Thread Starter hothbricks

    (@hothbricks)

    And…It works !!!

    Thanks for your outstanding support !

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WP-Insert and CLoudflare caching (GeoIP problem)’ is closed to new replies.