Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-08:00)

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by Bobby 2 weeks, 2 days ago.

Assisted by: Bobby.

Author Posts
August 13, 2024 at 7:56 am #16064929

desireeM

Background of the issue:
When logged in to wp-admin but viewing in a different language (so the url has &lang=)
If the WP auth cookie expired, WP will show a overlay for login. However the wp-login.php URL is not for the current URL but for the currently selected language.

e.g. 2 languages en and fr on example.com and example.fr
example.com/wp-admin/edit-tags.php?taxonomy=user_tag&trid=0&source_lang=en&lang=fr&admin_bar=1

Will contain

```

Session expired

hidden link" target="_blank" rel="noopener">Please log in again.
The login page will open in a new tab. After logging in you can close it and return to this page.

```

But it should be example.com/wp-login.php not example.fr/wp-login.php in this case

This matters since after the login, you are suddenly logged into wp-admin on example.fr instead of example.com

Symptoms:
wrong URL

Questions:
Please fix this bug

August 13, 2024 at 10:51 pm #16068166

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

In WPML->Languages-> enable the feature "Auto sign-in and sign-out users from all domains", does that help resolve the issue of needing to login to each domain separately?

August 14, 2024 at 2:38 am #16068556

desireeM

Please read the issue I encounter again, it has nothing to do with "needing to login to each domain separately"

August 14, 2024 at 10:10 pm #16072626

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

I understand the issue you are having, however, are you able to resolve it by using the feature I mentioned as a workaround? It is important to test this to debug this issue thoroughly and to give our team a deeper idea of what might be causing this.

NOTE: I am also updating our team about the bug you are experiencing so we can further review it.

August 15, 2024 at 5:10 pm #16075614

desireeM

No, it doesn't. Since the URL is still wrong.

August 15, 2024 at 9:27 pm #16076308

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **

I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

Thank you,
Bobby

August 18, 2024 at 2:08 am #16080674

desireeM

This issue happens on a completely new install of WPML. If you just install WPML and add a 2nd language you will be able to reproduce the issue.

August 20, 2024 at 8:29 pm #16088237

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

We are testing this and will update you once I have news.

August 21, 2024 at 5:11 pm #16091705

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

When you say "However the wp-login.php URL is not for the current URL but for the currently selected language."

If you have the French language selected since you are using different domains per language the URL will indeed be .fr .

Since you are signed out at that moment the system will not recognize the user rather simply just that you need to log in again therefore it prompts using the URL at hand.

After speaking with our team we should raise this as a feature request as it is not classified as a bug with WPML.

August 21, 2024 at 9:44 pm #16092286

desireeM

Pleas read the original description again. This has nothing to do with "recognizing the user". The incorrect URL is already printed at a time the user is still logged in (otherwise I wouldn't be able to access wp-admin in the first place)

Current URL:
hidden link
On this page (I am on .com) it outputs (check dev tools):
hidden link

Therefore, when the session expires, it will ask me to login on example.fr even though I am example.com

This is a bug. You output the wrong URL based on the fact that the lang=fr is in the URL.

August 23, 2024 at 7:14 pm #16099506

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Escalated for our team to review further, we will update here once we have news.

December 6, 2024 at 6:04 am #16484596

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

A fix will be included in a later release of WPML.

At the moment I cannot share an ETA.

This is a workaround you could use until then if needed:

In wp-content/plugins/sitepress-multilingual-cms/classes/url-handling/converter/class-wpml-url-cached-converter.php

change from:

public function convert_url( $url, $lang_code = false ) {
global $sitepress;

if ( ! $lang_code ) {
$lang_code = $sitepress->get_current_language();
}

to:

public function convert_url( $url, $lang_code = false ) {
global $sitepress;

if ( ! $lang_code ) {
$action = current_action();
if ( $action == 'login_url' ) {
if ( isset( $_COOKIE["wp-wpml_current_language"] ) ) {
$lang_code = $_COOKIE["wp-wpml_current_language"];
}
} else {
$lang_code = $sitepress->get_current_language();
}
}

Do note that this might interfere with the logic for login to the different domains and you might have to login twice (or multiple times)

The topic ‘[Closed] Viewing wp-admin in a different language – wp-login.php in wrong language, redirects to wrong URL’ is closed to new replies.