Support » Fixing WordPress » Based on IP select giolocation and language

  • Hello,

    I need to make code for select language based on ip address to geolocation.

    when user move on about us page from india it will be auto matik redirect in hindi page.
    when user from pakistan it will redirect from urdu page.

    please suggest best way. i have usng poly lang plugin.

Viewing 1 replies (of 1 total)
  • 
    $ip_address = $_SERVER['REMOTE_ADDR'];
    	
    $geopluginURL = 'http://www.geoplugin.net/php.gp?ip=' . $ip_address;
    		
    $geoip_response = unserialize( file_get_contents( $geopluginURL ) );
    		
    if ( ! empty( $geoip_response ) ) {
    			
    	$country_code = $geoip_response['geoplugin_countryCode'];
    
            // Condition to check id user is visiting from India
    	if ( 'IN' == $country_code ) {
    		wp_redirect( $url );
    	}
    }
    

    You can place url as per your need.

Viewing 1 replies (of 1 total)
  • The topic ‘Based on IP select giolocation and language’ is closed to new replies.