Skip Navigation

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

Problem:

When WPML's language format is set to Language name added as a parameter, TutorLMS dashboard URLs don't work as expected.

Solution:

Our compatibility team confirmed the issue and will work with TutorLMS team to fix this issue. And they provided a workaround which can be found here: https://wpml.org/forums/topic/trailingslashit-not-adding-to-the-end-of-url/#post-12824081

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

Last updated by Ahmed Mohammed 1 year, 10 months ago.

Assisted by: Ahmed Mohammed.

Author Posts
January 9, 2023 at 11:42 am #12776447

clareQ

We are using the plugin Tutor LMS which says it is WPML compatible. On our site is a sidebar generated by Tutor LMS. The links always come out formatted wrong.

Like this: hidden link

Rather than like this: hidden link

I found the section of code that generates it and it uses the function trailingslashit() which I see WPML says it supports here: https://wpml.org/errata/changes-in-the-way-wpml-handles-the-trailing-slashes-in-url-conversion/

This is the section of code from Tutor LMS that generates it:

public function get_tutor_dashboard_page_permalink( $page_key = '', $page_id = 0 ) {
if ( $page_key === 'index' ) {
$page_key = '';
}
if ( ! $page_id ) {
$page_id = (int) $this->get_option( 'tutor_dashboard_page_id' );
}
return trailingslashit( get_permalink( $page_id ) ) . $page_key;
}
January 9, 2023 at 1:36 pm #12777497

Ahmed Mohammed
Supporter

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

Hi there,

Thank you for contacting WPML support!

I understand that you're using TutorLMS, and the tutor dashboard URL is constructed incorrectly as follows: hidden link.

It looks like you're using Language name added as a parameter as the language URL format under WPML → Languages.

Could you please test switching to Different languages in directories and let me know if the issue is still there?

Looking forward to hearing back from you.

January 12, 2023 at 3:06 pm #12806579

clareQ

Hi there, yes if I switch to directories it seems to resolve the issue. Is this a known bug that will be fixed?

January 12, 2023 at 4:26 pm #12807399

Ahmed Mohammed
Supporter

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

Hi there,

> yes if I switch to directories it seems to resolve the issue.

Oh! Glad to hear that.

> Is this a known bug that will be fixed?

I have checked our records, and I could not find a report for that issue. So it needs to be reported to our compatibility team and TutorLMS team.

I have created this sandbox website: hidden link - could you please replicate the issue there and I will take it from there.

Looking forward to hearing back from you.

January 13, 2023 at 9:40 am #12811825

clareQ

Hi ok thanks. I contacted Tutor LMS about this and they said they were in contact with WPML about it. I am not sure if they actually are though!

I have installed tutor LMS and you can see the problem on this page: hidden link

January 13, 2023 at 11:51 am #12812889

Ahmed Mohammed
Supporter

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

Hi there,

> I contacted Tutor LMS about this and they said they were in contact with WPML about it. I am not sure if they actually are though!

I can see that TutorLMS team is working with our compatibility team but I could not a specific report for this specific issue.

> I have installed tutor LMS and you can see the problem on this page: hidden link

Thank you! I'm going to take this to our compatibility team and I will keep you posted whenever I have more information.

In the meantime, please let us know if you have any further questions. We're always happy to help!

January 16, 2023 at 7:53 am #12824081

Ahmed Mohammed
Supporter

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

Hi there,

I appreciate your patience while we were working on this.

Our compatibility team found a workaround for this issue and will work with the plugin's author to fix it permanently.

The workaround is to edit this file: /wp-content/plugins/tutor/classes/Utils.php

Change:

return trailingslashit( get_permalink( $page_id ) ) . $page_key;

to

if (apply_filters('wpml_setting', false, 'language_negotiation_type') == 3) {

			$permalink = get_permalink($page_id);
			$permalink = remove_query_arg('lang', $permalink);

			$my_current_lang = apply_filters('wpml_current_language', NULL);
			$url = trailingslashit($permalink) . $page_key;
			$url = apply_filters('wpml_permalink',  $url, $my_current_lang);

			return $url;
		} else {
			return trailingslashit(get_permalink($page_id)) . $page_key;
		}

Could you please try it and let me know how it goes?

Looking forward to hearing back from you.

January 18, 2023 at 10:00 am #12841385

clareQ

Thank you Ahmed the workaround you provided seems to work

January 18, 2023 at 11:52 am #12842383

Ahmed Mohammed
Supporter

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

Hi there,

> Thank you Ahmed the workaround you provided seems to work

Super glad to hear that 🙂

Our compatibility team will work with the plugin's author to implement this fix permanently.

I'm marking this ticket as resolved for now. Whenever you require any further assistance, please feel free to open a new ticket.