How to show/hide fields based on visitor's country? I have two fields (consider field_A, field_B). Anyone should see only one of these 2 fields based on their IP address:


If users from US access the page, only field_A should be visible.
For other countries, field_B should be visible. 


How can I achieve this?
You can make use of Geo Ip to do this. Install Geo Ip by following the instruction mentioned in the link http://www.beginninglinux.com/home/php/ubuntu-php-5-geo-ip

Make use drupal ip_address() function to get user ip address. 

function test() {
  $code = geoip_country_code_by_name($ip);
  if ($code == 'US') {
    //hide  field B
  }
  else {
    //hide field A
  }

}


geoip_country_code_by_name returns country code. I think this approach gives you solution.