Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing issues with your website where changing the language results in too many redirects, it might be due to a conflict with custom code.
Solution:
We found that the issue was related to a custom snippet called "Gate for not logged in users". To resolve this, we recommend deactivating the snippet. Here are the steps to follow:
1. Locate the custom code snippet in your website's codebase.
2. Temporarily deactivate the snippet by commenting it out or removing it.

function custom_redirect_to_specific_page() {
    if (!is_user_logged_in() && !is_page(109)) {
        wp_redirect(home_url());
        exit;
    }
}
add_action('template_redirect', 'custom_redirect_to_specific_page');

3. Check if the language redirection issue is resolved.
If you're not comfortable working with code or if the issue persists, we suggest reaching out to one of our certified partners for further assistance.

If this solution doesn't look relevant to your situation, please open a new support ticket with us.

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.

Tagged: 

This topic contains 1 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 4 months ago.

Assisted by: Long Nguyen.

Author Posts
January 31, 2024 at 7:38 pm

royH-4

On this website hidden link when we try to change the language, the page gets redirected too many times.

January 31, 2024 at 9:02 pm
February 1, 2024 at 5:09 am #15252756

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Roy,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

The issue occurs when the custom snippet "Gate for not logged in users" is activated.

function custom_redirect_to_specific_page() {
    if (!is_user_logged_in() && !is_page(109)) {
        wp_redirect(home_url());
        exit;
    }
}
add_action('template_redirect', 'custom_redirect_to_specific_page');

I deactivate this snippet and I can see the login page in second languages as well, please check the screenshots attached.

Note: I would like to inform you that helping you with custom code, is out of the scope of WPML, but I helped point you to the source of the problem you are having.
If you cannot fix the issue, I recommend you contact one of our certified partners who will be more than happy to help you with this. In this link, you will find a list of our certified partners: https://wpml.org/contractors/

Look forward to your reply.
Thanks

Monosnap FXGlobe Partners 2024-02-01 12-03-24.png
Monosnap FXGlobe Partners 2024-02-01 12-03-51.png
February 1, 2024 at 9:23 am #15253395

royH-4

The issue is sorted.