Skip to content Skip to sidebar

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
10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 - -
16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 - -

Supporter timezone: Asia/Jerusalem (GMT+03:00)

This topic contains 8 replies, has 1 voice.

Last updated by Alexander 3 hours, 3 minutes ago.

Assisted by: Itamar.

Author Posts
July 9, 2025 at 8:58 am #17217694

Alexander

Background of the issue:
I am trying to use the logout link in the WordPress admin bar, but it still contains the language prefix "/de/wp-login.php?action=logout" of a removed language. I had created three languages in WPML: German (default), English, and French. After relaunching the site, only English is the default language, and the other two are removed (not hidden) in WPML. However, there is still German and French content, and WPML/Languages suggests these can be deleted if not needed. We plan to reactivate these languages later. When someone with 'German' language selected in their WordPress profile clicks any logout link (for example in the WordPress admin toolbar) the URL of the logout link looks like this: hidden link. If I open this link I will see a 404 page, because the /de/* path no longer exists, as the language was removed. Changing the profile language to English removes the /de prefix, and the logout link works.

Symptoms:
The logout link still contains the language prefix of a removed language (hidden link), leading to a 404 page because the /de/* path no longer exists. The expected behavior is that all logout links should look like this: hidden link, as there is only one activated language left, which is English.

Questions:
Why does the logout link still contain the language prefix of a removed language?
How can I ensure that the logout link does not include the prefix of a removed language?

July 12, 2025 at 12:46 pm #17230208

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thanks for the details — this behavior is likely caused by a residual user language setting in their WordPress profile. Even though German has been removed in WPML, some users may still have it set as their preferred admin language, which causes WordPress to build the logout URL with /de/.

To resolve this, please ask the affected user to:

Go to their WordPress profile (/wp-admin/profile.php)

Change the language setting to English

Additionally, it's a good idea to refresh rewrite rules by navigating to Settings → Permalinks and clicking Save Changes. This helps clear any lingering path rewrites that might still reference /de/.

These two steps usually reset how the logout link is generated and should eliminate the /de/ prefix.

If those steps do not solve the issue, please let us know.

Best regards
Andreas

July 14, 2025 at 7:04 am #17231753

Alexander

Refreshing rewrite rules doesn't help. If you access the /de/ path, it no longer exists in the rewrite rules, because the language was removed.

The problem is the following code. WPML does not check whether the language someone has selected in the user profile still exists and always adds the locale prefix to the logout URL. It's not uncommon for someone to use WordPress in their language, even though that language isn't even offered on the website via WPML.

sitepress-multilingual-cms\classes\url-handling\wpml-wp-login-url-converter.php:

public function convert_user_logout_url( $url ) {
$current_user_id = User::getCurrentId();
if ( $current_user_id ) {
$user_locale = User::getMetaSingle( $current_user_id, 'locale' );
if ( ! empty( $user_locale ) ) {
$language_code = $this->sitepress->get_language_code_from_locale( $user_locale );
return $this->url_converter->convert_url( $url, $language_code );
}
}
return $url;
}

As you can see, the locale is read from the profile, translated into the prefix using the icl_languages table, and added to the logout link. A check must be integrated here to determine whether the language is still active, otherwise the rewrite rule for the prefix will no longer be active and the logout link leads to a 404 error.

July 15, 2025 at 8:40 pm #17239735

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

I'll continue to help you with this issue.

Could you please outline the steps I should take to replicate this issue?
Please write to me: "do 1. 2. 3." and so on.
If possible, send me a video demonstrating the problem.
You can use the free online screencast service Komodo - hidden link.
Then if I can replicate this problem, I'll esclate it to our second-tier supporters.

Thanks,
Itamar.

July 16, 2025 at 7:51 am #17240350

Alexander

Steps:

1. Login to the WordPress backend

2. Go to your user profile: /wp-admin/profile.php

3. Change the "Language" to a language, that is not enabled in WPML, for example Spanish.

4. Open the black WordPress toolbar menu in the top right corner where it says "Welcome/Hola <Your name>" and then click the bottom logout link ("Salir" in Spanish) in the dropdown menu.

The link contains the language prefix of the user-specific language. In this example, /es for Spanish:
/es/wp-login.php?action=logout&_wpnonce=xxx
^^^

5. Because this language is not activated in WPML, the logout link leads to a 404 page because the language prefix was not registered in the WordPress rewrite rules.

The solution is to check whether the current backend user language is enabled in WPML. Otherwise, the language prefix cannot be added in the following WPML function:

function convert_user_logout_url() (Path of file: sitepress-multilingual-cms\classes\url-handling\wpml-wp-login-url-converter.php)

July 17, 2025 at 4:19 pm #17247128

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

Thanks for providing the detailed steps. However, I'm unable to replicate this problem on a fresh WordPress installation with WPML. When I click the log out link, I get logged out, and I don't get a 404 page. Please see a video I recorded here:
hidden link
Your custom child theme or one of the plugins you use on your site might cause this problem. If possible, try it when the theme is switched to a default WordPress theme and all the third-party plugins are deactivated.

**** Important! Please make a full site backup (files and DB) before you proceed with those steps****

You can check my sandbox site here:
hidden link
If you find I missed something, please let me know.

Regards,
Itamar.

July 17, 2025 at 6:22 pm #17247560

Alexander

I noticed that in the sandbox, no /es/ was written before the logout link. This was probably because no translated content existed yet. I added a page and translated it, and then /es/ was added as well. But the logout still worked.
I then did some research and found out that WPML creates redirects for language-dependent logouts in the htaccess. You can see that here: https://wpml.org/forums/topic/wpml-adding-language-folders-to-htaccess/

Does it do this automatically for every language a user has selected in their profile? Then there should also be an entry for Spanish in the sandbox, right? If so, that would be the reason when a system doesn't have write access to the htaccess. Then the call to a language specific logout fails. I'll test this thoroughly again tomorrow. Thanks for the help!

July 20, 2025 at 8:44 am #17252784

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

Yes, it should also work with Spanish, as you can see on the provided sandbox site. Please proceed with the suggestion to try this case in a minimal environment (as was suggested in the errata page), and let us know if you require further assistance with this issue.

Regards,
Itamar.

July 21, 2025 at 7:50 am #17253963

Alexander

Please re-enter your sandbox. I changed the user language to Portuguese, and now when you use the logout link in the top right corner of the menu, you get a "File not found" error, not even a designed 404 page like on my sites. I also have this problem on minimal installations.

Logout-Link looks like this: hidden link

I checked whether WPML creates real rewrite rules to redirect the /<language-prefix>/wp-login.php links. I couldn't find any entries. Only in the htaccess, but not for all languages. Actually, only the enabled WPML languages. Why Spanish works in the sandbox is a mystery to me! But Portuguese doesn't!

So it would be really important that only the enabled WPML languages are supported in the "convert_user_logout_url" function.