How to display Drupal blocks based on location - Drupal geolocation block

Step 1: 
Install and configure the module Smart IP

The module Smart IP allows you to identify the users location with a very broad range of data sources.

Install the module, choose a method and configure the module accordingly.

Step 2: 
Create a block and apply PHP code

Create a block, change the text format to "PHP code" and add the following PHP code:

$smart_ip_session = smart_ip_session_get('smart_ip');
if ($smart_ip_session['location']['country_code'] == 'XX') {
echo '<img src="/sites/default/files/country.jpg" title="Country XX" alt="Country XX" border=0>';
print "<h1>This Image block only displays in the country XX</h1>";

"XX" represents the country code to be changed. You can add multiple country codes, allowing you to define in which countries the Drupal block shall be shown. You can add any PHP commands after the if logic to display or execute whatever you want. You can also change the logic to "if not" allowing you to not display the Drupal block in certain countries.

Drupal smart IP module

Drupal themes to be compared