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 thread is resolved. Here is a description of the problem and solution.

Problem:
Unable to execute auto redirect using "wpml auto detect and redirect by ip" plugin

Solution:
The plugin is not using full converstion of wpml_permalink which caused the issue, To fix
Open the file in the patth ⁨/wp-content⁩ /plugins⁩/⁨wpml-auto-detect-and-redirect-by-ip⁩/code/⁩Popup.class.php at line 71 find the code

$wpml_permalink = apply_filters( 'wpml_permalink', $wpmlP, $mappedLanguage ); 

Replace with

$wpml_permalink = apply_filters( 'wpml_permalink', $wpmlP, $mappedLanguage, true ); 

This will solve your issue.

Relevant Documentation:
https://wpml.org/wpml-hook/wpml_permalink/

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by williV 1 month, 2 weeks ago.

Assigned support staff: Raja Mohammed.

Author Posts
August 29, 2019 at 9:30 am

williV

I installed the plugin WPML redirect based on IP and something went wrong, but the developer points my towards you guys. I installed the plugin and it used to work, then suddenly for the Flemish (Belgium) language it was redirecting to a page that didn't exist. According to the developer of th eplugin, it uses the main language redirects from within WPML so he couldn't do anything with it. Then I tried to rebuild all translation links via WPML -> settings -> Translate Link Targets. This was causing an overload in the database and then I rebuild the cache via WPML -> support -> troubleshooting -> Recreate ST DB cache tables. Then the database was fine again but now the WPML redirect based on IP popup isn't appearing anymore at all.

According to the plugin pages here, the plugin is approved on compatibility.

Link to a page where the issue can be seen: Homepage of hidden link

I expected to see: A popup that asks me to redirect to the right language

Instead, I got: norhing at all now.

August 29, 2019 at 10:23 am
August 29, 2019 at 10:36 am #4480211

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi there,

Please let me know the status here.

Thanks and regards
Raja

August 29, 2019 at 11:17 am #4480451

williV

Hi Raja,
Thanks for your help so far, from my end status is still open, I will inform you when the plugin key is updated.
I look forward to the feedback of the plugin compatibility team.
rgds,
Willi

August 30, 2019 at 4:50 am #4484727

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Sure willi, Thanks for the update,

Please note the sandbox site will expire automatically if kept inactive for 7 days.

August 30, 2019 at 7:32 am #4485059

williV

Hi Raja,
Just got feedback from the developer of the plugin that one extra license activation was enabled and I activated the plugin on the test site. Can you continue with this?
Thanks.
rgds,
Willi

August 30, 2019 at 1:59 pm #4487579

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I am unable to reproduce the issue in the test site,
The redirection works well without any issue. please refer hidden link

Please test the same with your country IP share the results.

- Make sure there is not redirect rule in YOAST affecting the functionality

- I would suggest testing the issue by disabling all non-WPML plugins except the WPML Redirect Based on IP Country plugin, check if the issue persists.

- If the issue disappears try activating the plugins one by one to identify the conflicting plugin

Let me know the results.

Kind regards
Raja

September 1, 2019 at 12:22 pm #4492487

williV

Hi Raja,

Thanks for your reply, I did all the tests and it always stays the same.
Is there any place in the database I can check what language code is linked to the BE version? Or can I see every linked language code to a specific language.
Also, perhaps this might be something, the BE language is a language that I've created myself as this is Dutch but different the the Dutch from The Netherlands. I also gave it the nl_BE locale which is not standard coming with WPML, might this cause an issue?

Rgds,
Willi

September 2, 2019 at 5:13 am #4494461

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It seems the plugin stores the mappings in the wp_options table with option name "crivion-wpml-autodetect-mappings " as serialised array. Check if your custom language mapping is added properly.

I don't think custom language might be an issue. However, let me know the mapping results from the database.

Kind regards
Raja

September 2, 2019 at 8:21 am #4495233

williV

Hi Raja,
Thanks for the update.
I see that not every language is listed in my record:
a:4:{s:2:"US";s:2:"us";s:2:"GB";s:2:"en";s:2:"NL";s:2:"nl";s:2:"BE";s:2:"be";}
I also notice that you have different language as well, the IN (international == en and FR) that I can see in the screenshot?
rgds,
Willi

September 2, 2019 at 11:31 am #4496583

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm not sure what's causing the issue here. Maybe its time to test with the snapshot of your site as the issue cannot be reproduced on a clean installation.

Are you able to create a snapshot of the site using a duplicator package? if not already done can you please initiate the process again and share the package here. I have enabled private fields for you to securely share the details.

September 2, 2019 at 12:10 pm
September 3, 2019 at 10:56 am #4503717

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I am having some issue to make the plugin work on the local environment, I will update you once I have something to share with you.

September 3, 2019 at 1:59 pm #4505029

williV

Ok, thanks Raja. Hope you can find a solution.
rgds,
Willi

September 4, 2019 at 2:30 pm #4512017

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Finally, I am able to find a solution to your issue.

Please open the file in the patth ⁨/wp-content⁩ /plugins⁩/⁨wpml-auto-detect-and-redirect-by-ip⁩/code/⁩Popup.class.php at line 71 find the code

$wpml_permalink = apply_filters( 'wpml_permalink', $wpmlP, $mappedLanguage ); 

Replace with

$wpml_permalink = apply_filters( 'wpml_permalink', $wpmlP, $mappedLanguage, true ); 

This will solve your issue.

The issue here is your home page has a different slug which has translated URL slug, The code in the plugin is not using full conversion of URL which resulted in wrong WPML permalink URL and hence redirected to default language home page.

The issue is explained here https://wpml.org/wpml-hook/wpml_permalink/

You can pass on the fix to the plugin developer for their consideration.

Let me know if you can handle this yourself

Kind regards
Raja