Frontpage according to geolocation

Frontpage according to geolocation

by Stephan Tedesco -
Number of replies: 4

We are planning to expand our Moodle site and include another school from the nearby country (10km accross the border). 

We have here some difficulties with the concept, so here are the facts: 


  • Each school has different language
  • Each school has different courses - so we have to show different courses on the front page
  • Privacy in the footer has to be different for each school
  • Theme will be the same


Using roles & audiences we can manage to show the different content to the targeted group/school. Problem would be the front page, when guest users are visiting it. 

Did someone has experience with similar problem? How to enable geolocation services for guest, visitng the front page. 


Thanks for a feedback. 

Regards, 


S. 

Average of ratings: -
In reply to Stephan Tedesco

Re: Frontpage according to geolocation

by Stuart Mealor -

You can't restrict Guests by geolocation, because you don't know where they are visiting from, and Guest settings would apply to all Guests.

But of course you do not need to show any Courses on the Frobt Page to Guests if you don't want to !

Then no-one will see Courses until they are logged in, and then you processs for showing certain courses to specific schools kicks in smile

In reply to Stuart Mealor

Re: Frontpage according to geolocation

by Stephan Tedesco -

The problem is, that we want to offer courses to the guests, according to specific geolocation. 

In reply to Stephan Tedesco

Re: Frontpage according to geolocation

by Martin Greenaway -

In that case, I guess you would probably need to intercept the call to the homepage with a custom page whose only job is to determine the source IP's geolocation, and then sets the language before calling the real Moodle homepage.  It doesn't sound like an ideal solution.

In reply to Stephan Tedesco

Re: Frontpage according to geolocation

by Dan Poltawski -

Note that if you have $CFG->autolang enabled, Moodle will try and display the site in the language of the browser requesting it using Accept-Language. If the browsers of the schools are setup to their native language then this can be quite a reliable solution. We do that here on the moodle.org frontpage.

You can use $SESSION->lang to determine the language of the guest you can even use https://docs.moodle.org/32/en/Multi-language_content_filter to do this without coding.

Another alternative is to use iplookup_find_location() to get a guess from their ip, but I would say thats probably less reliable than language if you have differences there.

Average of ratings: Useful (3)