Skip Navigation

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

Problem:
The client is experiencing an issue with the BetterDocs plugin on a multilingual site using WPML. When attempting to switch languages on a specific page, the redirection fails, stopping at an intermediate page instead of reaching the correct translated page. This issue is observed with incorrect URLs being generated for language switches.

Solution:
We recommend modifying the BetterDocs plugin code to ensure correct URL generation when switching languages. Here are the steps:
1. Open the file

wp-content\plugins\betterdocs-pro\includes\class-multiple-kb.php

.
2. Locate the function

doc_category_link

around line 695.
3. Replace the existing code with the following snippet:

public static function doc_category_link($termlink, $term, $taxonomy)<br />{<br />    if ($taxonomy != 'doc_category') return $termlink;<br /><br />    $kb_slug = self::kb_slug();<br /><br />    // WPML Workaround for compsupp-6478<br />    if (class_exists('SitePress')) {<br />        $kb_arr = get_term_meta($term->term_id, 'doc_category_knowledge_base', true);<br />        $kb_slug = $kb_arr[0];<br />    }<br /><br />    if (empty($kb_slug)) {<br />        $category = get_term_by('slug', $term->slug, $taxonomy, ARRAY_A);<br />        $kb_arr = get_term_meta($category['term_id'], 'doc_category_knowledge_base', true);<br /><br />        if (empty($kb_arr[0])) {<br />            $kb_slug = 'non-knowledgebase';<br />        } else {<br />            $kb_slug = $kb_arr[0];<br />        }<br />    }<br /><br />    return str_replace('%knowledge_base%', $kb_slug, $termlink);<br />}

This modification should correct the URL generation issue. If this solution does not resolve your problem, or if it seems outdated or irrelevant to your case, please visit our support forum to open a new ticket. We also highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins.

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 44 replies, has 2 voices.

Last updated by Osama Mersal 2 years ago.

Assisted by: Osama Mersal.

Author Posts
September 8, 2022 at 4:26 am #12009931

alexeyK-12

we have given you access in emails before.
Just take the same dotudy.
But before you start your work, please let us know at what time you will be watching our site, so that we do nothing. According to Greenwich.

September 8, 2022 at 8:48 am #12011529

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

I can work on your site starting now, and to 4.00 PM (GMT). Please let me know if this time window is suitable for you.

Thanks,
Osama

September 9, 2022 at 4:27 am #12019067

alexeyK-12

Yes OK. just do not reconfigure themselves something. We need to do it ourselves according to your examples in order to control all changes (for example, links will become broken)

September 9, 2022 at 11:05 am #12021547

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

1) I tried to login to check, but I got an error message. (Unknown email address. Check again or try your username.)

2) I won't change anything. I'll check the strings and the slug translation. However, if I couldn't spot the issue, I would need you to replicate the issue on the sandbox site for further debugging or if you have a staging site to debug the issue.

Regards,
Osama

September 11, 2022 at 8:23 am #12028837

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for the access details. I've checked your site and noticed two things that might cause the issue:

1) The knowledge base slug and the guide page slug are the same, which could cause the issue. (Kindly check this hidden link)

Would you please change the guide page slug to be (guides) in all languages?

2) The category slug is different in the better docs settings than the WPML settings. (Kindly check this hidden link)

Would you please change it in the better docs settings page to match the one in WPML settings?

After the above steps, please resave the permalinks, clear the cache, and check if the issue persists.

Regards,
Osama

September 13, 2022 at 9:49 am #12041177

alexeyK-12

betterdox answer:
Hello Alexey,

I have uploaded BetterDocs and BetterDocs PRO to the SandBox website. I hope the WPML team will help you to fix this.

I am sorry for this delay. Using all the BetterDocs default features, then the WPML will work smoothly. I noticed that you have made some pages in a custom way and also applied some custom conditions. Maybe it could be a reason for this issue.

Thank you

Congratulations, you now have access to the pro version.

September 13, 2022 at 9:56 am #12041223

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi Alexey,

1) Thanks for your update. Could you please check my previous reply and let me know if the suggestions mentioned helped you fix the issue?

2) Thanks for uploading and activating the BetterDocs plugin on the sandbox site. Would you please replicate the issue on the sandbox? If the issue is replicable, please let me know the steps to reproduce it.

Thanks,
Osama

September 14, 2022 at 5:29 am #12048023

alexeyK-12

there is also this answer wplms:

Thank you, the pages are loading in WordPress. This issue is not related to WPLMS as apart from the App section or Courses or Profiles rest of it is like a regular WP theme.

Everything in the issue is related to third party, third part post type, third party taxonomy, third party interface. I am sure the issue lies between BetterDocs + WPML.

However, I can see in the source the link generated seems correct but it kind of redirects to the page you have.

hidden link

redirects to

hidden link

Please check "Tool levels" is translated and synced in WPML. Since this is heirarchial taxonomy.

these are your recommendations hidden link
not yet fully verified.

September 14, 2022 at 9:22 am #12049405

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

1) Thanks for your update. I'm not sure if WPLMS is related to this issue, but they said it's not related.

2) Kindly let me know the result when you test changing the Guide page's slug and the categories' slug.

Thanks,
Osama

September 21, 2022 at 6:52 am #12091587

alexeyK-12

Hello.
Sorry.
There were urgent questions.
I will solve them and proceed to this issue.

September 21, 2022 at 9:29 am #12093111

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Sure, no problem; please take your time and let me know when you proceed with this issue.

Regards,
Osama

October 26, 2022 at 9:00 am #12313111

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

This ticket has been opened two times, and waiting for your reply regarding my suggestions here. (https://wpml.org/forums/topic/language-switcher-not-working-properly/page/2/#post-12028837)

However, you didn't reply, so our system closed the ticket.

Please let me know the result of the mentioned tests.

Best regards,
Osama

October 27, 2022 at 9:32 pm #12327297

alexeyK-12

Hello.
We have carried out tests on your recommendation :

1. Here is a video where you can see that we did everything as you asked hidden link
Did not help.

2. Here is what we did:
hidden link
hidden link
Maybe they did something wrong...
Does not work

October 28, 2022 at 11:09 am #12331341

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your update. I'd need to consult our compatibility team regarding this issue, but we need to replicate the issue on a fresh installation in order to isolate it.

Could you please log in to this sandbox site, upload the latest version of BetterDocs, and activate the pro version? (hidden link)

After that, please create a knowledgebase, category, and post to replicate the issue. If the issue is replicable to the sandbox site, please let me know the steps to reproduce it, so I can escalate the issue.

Thanks for your cooperation

Regards,
Osama

October 31, 2022 at 3:43 pm #12344497

alexeyK-12

so I gave you the answer beter doks, they gave you a free version of their plugin for testing.
I can’t do this (namely beterdox)