I want that the admin user to only be able to log in from a certain country, and that the other users that are not administrators will be able to log in from every country.


1 Answer 1


I would use the Smart IP module (https://www.drupal.org/project/smart_ip), you can add an extra validation on the login form that checks the country (https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_validate/7).

You should check if the username exists on validation, when it exists you can check it's role and when it's the administrator role you make sure only users with the IP of your selected country can log in as admins.

There might be easier ways.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.