On a Drupal 6 site I am trying to display blocks on my site based on user's country.
- To do this I had to install 'IP to Country' module
- Updated IP to Country
Created a new block and added the following code into the block body to print the user's country code:
<?php $co=module_invoke('ip2cc','get_country',$_SERVER['REMOTE_ADDR'];); print($co->country_code); ?>
Then, under 'Show block on specific pages' selected 'Show if the following PHP code returns TRUE (PHP-mode, experts only).' and then added the below mentioned code, so that the block is displayed based on the country ID.
<?php $co->country_code == "IN" ?>
After doing all these the block is getting disabled for the ID mentioned, eg: If 'IN' is mentioned the block should only be displayed for Indian visitors, but the block is actually being disabled.