Skip Navigation

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

Problem:
The client is experiencing an issue where changing the user language with a logged-in user does not update the user language in the WordPress user settings. Additionally, there is a problem with translating the WooCommerce email footer text using the

wpml_switch_language_for_email

function.
Solution:
To ensure the user's Profile language updates based on the language switcher selection, go to "Users > Profile" in the WordPress dashboard and enable the "Set admin language as editing language" option under "WPML Language Settings". This will align the user's language preference with the language chosen via the language switcher.

For the separate issue regarding the WooCommerce email footer text translation, we ask the client to create a new support ticket, as we handle one issue per thread to keep discussions clear and focused.

Please note that the solution provided might be outdated or not applicable to your case. If the solution does not resolve your issue, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket.

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

Last updated by Prosenjit Barman 1 year, 2 months ago.

Assisted by: Prosenjit Barman.

Author Posts
February 19, 2024 at 9:33 pm #15320163

johannesG-17

When I change the user language on my page with a logged-in user, the user language is not updating inside the user settings from WordPress.

This is my current workaround and describes what I exprect:

/**
* Update user locale when changing language
*/
add_action( 'wpml_language_has_switched', 'wpml_language_has_switched_action' );
function wpml_language_has_switched_action() {
if ( ! is_user_logged_in() ) {
return;
}

$current_lang = apply_filters( 'wpml_current_language', null );
$user_id = get_current_user_id();

if ( ! empty( $current_lang ) ) {
switch ( $current_lang ) {
case 'de':
update_user_meta( $user_id, 'locale', 'de_DE' );
break;
case 'en':
update_user_meta( $user_id, 'locale', 'en_US' );
break;
}

}
}

February 19, 2024 at 10:27 pm #15320212

johannesG-17

Also, when I use wpml_switch_language_for_email inside an email template, the __() function get's translated correctly but the WooCommerce email footer not: apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) )

It's still in the page language and not within the user language...

February 20, 2024 at 12:19 pm #15322583

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thanks for contacting WPML Support.

To adjust the user's Profile language based on the choice made via the language switcher, navigate to "Users > Profile" in your WordPress dashboard. There, activate the "Set admin language as editing language" option found under "WPML Language Settings". This action will ensure the user's language preference is updated according to the language selected via the language switcher.

However, if you're looking for something else than what I understood, I kindly request you to share more details. This will help me gain a clearer understanding of your needs and offer more targeted assistance. Looking forward to your response.

I also would like to inform you that we're allowed to discuss one issue per thread to maintain clarity in each thread. Since the other issue with Email is a different issue, kindly create a new ticket for that by including as much as information you can. One of our support team members will then pick up the ticket and provide the necessary assistance. I hope you can understand the matter.

Best regards,
Prosenjit

February 20, 2024 at 2:03 pm #15323147

johannesG-17

Thanks.