Default country
Content type and behavior
Drupal 8 Release


This module helps to create country specific Node's i.e. Node will be hidden for the selected countries, the module also has an option to invert its default behavior i.e. you can set the modules functionality to show nodes for selected countries only. It detects and gets User's country from Ip2Country information and based on this it shows/hides nodes.

Note: This module denies or allows access to node based on the countries selected in the node edit form. It does not hide the displaying/rendering of nodes in listing e.g. Drupal's front page listing of nodes, instead it provides a $node->csn_hidden value to the template and in node_load object to determine whether to display the nodes at template level or any other custom rendering of nodes. $node->csn_hidden contains 1 for hidden nodes and 0 for non-hidden nodes. You can also bypass node access restriction for user roles.


This module requires following modules as dependencies-

Installation and Configuration:

  • Download and enable module through admin/modules.
  • Go to Structure -> Country Specific Nodes, select content types and click Save to attach country selection field to the selected content types, unchecking will remove country selection field from respective content types. You can also invert the functionality of module by selecting content types under Invert Functionality.
  • Go to Structure -> Country Specific Nodes -> Set Default Country to specify the default/fallback country if the users IP is not been detected by IP2Country (in rare cases).
  • Also note that this module adds a $node->csn_hidden value to the node object as 0/1 to indicate that this node is hidden or not while rendering a node (0 -> not hidden, 1 -> hidden).

Once enabled, it creates a field which can be attached to any content type through the modules configuration page.

7.x.2.x version adds region support, you can select regions in the country selector field now. Please note that we will soon work on the upgrade process from 7.x-1.x to 7.x-2.x. Please use 7.x-2.x as a fresh install for now.


This project is originally written by Makarand Chavan along with co-maintainer Sandeep Kumbhatil and Vikrant Ramteke

Project Information