MULTILINGUAL WITH COUNTRY DIFFERENT AGES
-
HI,
I would like to know, if it’s possible to have an age asign to a country.
I’m developing a website with 3 languages with WPML but have different age limitation by country.For exemple for the US it’s 21 and for France it’s 18.
and I’ve a listing of country with different age limitationThanks for your help
-
Hi @aboutalexg,
That should be there by default if WPML (or polylang) are installed. If you set the CMS to “All Languages” on the Age Gate settings page you should see multiple boxes like this:
Thanks
PhilThanks for your quick answer
I have another question how it’s going to work if I have only one translation for English (United kingdom > 18 years old and USA > 21 years old…)
And if I want Bresil > 18 years old and to be redirected to the English version.it’s perhaps WPML stuff but it’s linked to your plugin
Thanks
AlexHi Alex,
This is a bit trickier. Are you setting something to say what country they’re in?
A way to do it would be to add a country selector to the Age Gate form, then do some hooking into the Age Gate code.
There’s something similar in this question, where you add a select to the Age Gate form. I think you may need to set an additional location cookie. But it’s certainly a starting point.
Happy to help out if you need more info.
Thanks
PhilThanks, I’ve modify your plugin to feet to my problem and it’s working great, for each country I give an different age and I add a second argument “lang” to your script.
(here is the link https://we.tl/t-jwxTQe2enM)Now I need to link it with WPML to display the good language with the good country,
how can I redirect to the good URL for each language, if they have a the good age to see the content ?and I need to translate each country name that are in the PHP file in french and spanish
How can I traduce it in other languages ?Thanks for you help
I’ve had a look at what you had. Needs some tweaks to get you where you need to be.
Have a look at this slightly updated version: https://we.tl/t-Pn0s9BSuee
Theres a function for if you are using the PHP age gate and one for JavaScript. It’s not perfect as I’m not sure of your WPML setup but a couple of Javascript and/or JS and you should be able to get it to where you want.
You should be able to do any translations in the WPML strings translator.
Anything else you need should be standard WordPress/PHP/JavaScript now, but there’s also docs for Age Gate here
Hope it helps
Thanks,
PhilThanks Phil,
I’ve tryed but it doesn’t work…
Is it possible to send you a private message ?Hi
It was not working with MAMP but working online.
offline I have this URL in home page
http://localhost:8888/myweb/en/and when I use the age gate and select french I’ve this URL
http://localhost:8888/fr/
instead of
http://localhost:8888/myweb/fr/Hi @aboutalexg,
Looks like that’s some path issues to where your install is, unless you’re site is going to be in a directory I’d recommend setting up virtual hosts with MAMP and using the default ports.
I can’t find the code I sent you over now, but you should be able to add
site_url()in the redirect to make sure it’s going to the right place. If you can send the code back I’ll check the logic.Thanks
Philhi @philsbury
Thanks for your answerHere is the extension of your age gate countries
(https://we.tl/t-XllM1K2mdw)I’ve found another problem
my default language is English http://www.mywebsite.com/en
When I use the age gate on the home page http://www.mywebsite.com/en
no problem it can redirect to my 3 languages
http://www.mywebsite.com/en
http://www.mywebsite.com/es
http://www.mywebsite.com/frbut when I use it on this url http://www.mywebsite.com/fr or http://www.mywebsite.com/es
it works for this 2 languages, it can redirect to my french and spanish
http://www.mywebsite.com/es
http://www.mywebsite.com/frbut if I choose english in the age gate it stays in the french if I’ve load the http://www.mywebsite.com/fr or stays in spanish if I’ve load the http://www.mywebsite.com/es
Hi @aboutalexg,
These new issues aren’t really related to Age Gate as such.
Going back to the MAMP issue, as I thought the redirect in the example code assumed the site was in the root.
The redirection problems are from how Polylang works, it stores a cookie and redirects you to the language you previously selected. That will need to be changed before redirection to make your functionality work. I think you can turn it off somewhere, but it’s probably useful to real users.
I’ve updated the example which you can find here, but it is just an example so you may need to modify it to fit exactly your needs.
https://www.dropbox.com/s/ajtpadr9f073j3n/age-gate-countries.zip?dl=0As the Age Gate related parts of the question have been answered I’m going to set this as resolved.
Thanks
PhilThanks for your update but I work with wmpl
@aboutalexg, you do, sorry! Explains why I couldn’t find the original code in my Polylang sandbox!
Most of it will still work apart from the redirect as they share some functions, give this a try:
https://www.dropbox.com/s/0u5m7x0abluogy8/age-gate-countries-wmpl.zip?dl=0There’s a couple of
error_logcalls in there you’ll want to remove before going to production.Thanks
Phil
The topic ‘MULTILINGUAL WITH COUNTRY DIFFERENT AGES’ is closed to new replies.