This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 7 replies, has 2 voices.

Last updated by Bruno Kos 4 months ago.

Assigned support staff: Bruno Kos.

Author Posts
June 10, 2019 at 4:22 am #3985129

patt-2

We have 3 regions customers, US, EU & Asia, I will assign region to them when they registered. I want to restrict some pages for them to read.
For example, when US customers logged in, I only want them to read US pages, & restrict EU pages. When they go to EU page, is it possible to redirect to US pages?

June 10, 2019 at 10:13 am #3986595

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

WPML only offers browser language redirection:
https://wpml.org/documentation/getting-started-guide/language-setup/automatic-redirect-based-on-browser-language/

As explained in this answer as well:
https://wpml.org/forums/topic/how-to-redirect-visitors-based-on-their-country-not-browser-language/#post-2488928

However, your case may be much more complicated because you are not targeting specific countries, but much wider areas. Perhaps you should consider using some sort of a redirection plugin that would help you specify which country belong to which of these regions and then redirect appropriately.

This would not be even WPML-related, but you will need to search for any WordPress plugin allowing you to make such redirects. I could also point you to our contractors who are experienced developers:
https://wpml.org/contractors/

Maybe they can even achieve these using various htaccess redirect rules, but in any case this would be outside of the scope of work WPML support can provide.

I'm not able to suggest any specific redirection plugin for WordPress because personally I have never done a redirection of that kind, so I'm not sure which plugin will be the most appropriate for that.

Let me know if I can answer anything else!

Regards,
Bruno Kos

June 13, 2019 at 4:36 pm #4015749

patt-2

Hi Bruno,

Thanks for your reply.

I follow the post :
https://wpml.org/wpml-hook/wpml_switch_language/

try to add below code to functions.php

function hkp_icl_set_language($query) {
	if ( user_can ( $current_user, "customer" ) && $query->is_main_query() ) {
		do_action( 'wpml_switch_language', "en-hk" );
	}
}
add_action('pre_get_posts', 'hkp_icl_set_language');

Nothing changed.

I also check : https://wpml.org/forums/topic/set-language-in-code-before-page-loads/

It also not work.

Would you please inform how can I force change the language?
Thanks.

Regards,
Conni

June 14, 2019 at 5:57 am #4018615

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Can you tell me to which language should your code redirect to? I checked list of languages in the latest Firefox and I do not see any language which has en-hk language code, so it could be that it does not recognize it.

Regards,
Bruno Kos

June 14, 2019 at 1:25 pm #4021743

patt-2

Hi Bruno,

The language code setting as attached image LanguageSetting.JPG

I make a sample page to test please login as customer below:
hidden link

login url: decca.webdesign-hk.net/my-account
id: member
password: test_20190614

It won't change to AS language page :
hidden link

can I force change the language to en-hk ?

Best regards,
Connie

June 14, 2019 at 2:20 pm #4022001

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

can I force change the language to en-hk ?

The only " forcing" of the language would be if you use the language with this language code is as a default language, and perhaps try use your code to render the content from other languages.

However, as I noted in my previous message, for example I'm unable to set this language in the Firefox - the language with this language code en-hk - so I'm not sure how would any code redirect according to it or which language should it represent in fact?

Regards,
Bruno Kos

June 14, 2019 at 2:43 pm #4022265

patt-2

Hi,

Now I change the language code to "zh", But the functions still not work.

By the way, how to check the language setting in the Firefox?

Regards,
connie

June 15, 2019 at 6:09 am #4025671

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

You can change your browser language in the options of the browser (see the image). However, based on the complexity of the issue and your scenario, I definitely suggest you reach out to our contractors who will help you code this and properly test it in all scenarios:
https://wpml.org/contractors/

On a side note, you can also have a look at this, Perhaps this code could also help you with this:
https://wpml.org/forums/topic/set-users-default-language-using-php/#post-3215418

In any case, I definitely think that going with contractors will be the best route in this case.

Regards,
Bruno Kos

The topic ‘[Closed] Display specify language for specify region customers’ is closed to new replies.