1

On a Drupal website I want to redirect the visitor to a landing page based on the users location. I need this to be more specific than just the users country, but rather I need the province inside the country. When the user does not allow to be located, the user will go to the standard landing page...

Is there an (easy) way to achieve this? I am fairly new to the world of Drupal.

1

I've had pretty good results previously with SmartIP, and now there is Rules integration which can react to which country the user is in.

So you should be able to set a Rule similar to the following psuedo-rule:

EVENT:

Page is going to be viewed

CONDITION:

  • Page is: Front page
  • IP Address is in country: whatever country you want

ACTIONS:

Go to page: YOUR COUNTRY SPECIFIC LANDING PAGE

I know you said you were new to Drupal, so you can find some really useful Rules tutorials at NodeOne: Learn the Rules Framework.

EDIT

I've just twigged you said you want it to the province level rather than country (sorry, that was glaringly obvious - my fault), so you might be looking at some custom code.

Last time I used it, I used SmartIP to get the latitude and longitude of the user, and then the Location API for the nitty gritty.

You should be able to combine this with hook_init() and drupal_goto() to redirect the user to the relevant page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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