Load different content for users from different country [closed]

You may have to use a web service to get the user country using the user’s IP. There are a lot of them out there. I will tell you about one of them which is IP API . Here how to use it:

$ip = $_SERVER['REMOTE_ADDR'];
$return = wp_remote_get("http://ip-api.com/json/".$ip);

if ( is_wp_error( $return ) )
            return false;

$data =  json_decode( wp_remote_retrieve_body( $return ) );

the $data object will be an associative array:

    Array(
        [status] => success,
        [country]=> COUNTRY,
        [countryCode]=> COUNTRY CODE,
        [region]=> REGION CODE,
        [regionName]=> [REGION NAME],
        [city]=> CITY,
        [zip]=> ZIP CODE,
        [lat]=> LATITUDE,
        [lon]=> LONGITUDE,
        [timezone]=> TIME ZONE,
        [isp]=> ISP NAME,
        [org]=> ORGANIZATION NAME
)

You can fetch the country name or even the city name. and check them with if else statements.