Skip Navigation

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

Problem:
If you're developing a site and want to enable switching the WordPress account interface to the user's language of preference using WPML, but find that when a user registers with a non-English language and logs into their control panel, the interface remains in English.
Solution:
We recommend adding the following custom code to your theme's functions.php file:

add_action('user_register', function($user_id) {<br />    $current_language = function_exists('wpml_get_current_language') ? wpml_get_current_language() : get_locale();<br /><br />    if (!empty($current_language)) {<br />        update_user_meta($user_id, 'locale', $current_language);<br />        remove_action('personal_options_update', 'wpml_update_user_locale'); <br />        wp_update_user([<br />            'ID'     => $user_id,<br />            'locale' => $current_language<br />        ]);<br />    }<br />}, 20);

Please test this code in a staging environment before applying it to a live site, as this custom code is a courtesy and is not officially supported by us.

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, we 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. If needed, please open a new support ticket at our support forum.

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

Last updated by Osama Mersal 1 month, 2 weeks ago.

Assisted by: Osama Mersal.

Author Posts
February 26, 2025 at 1:10 pm #16751065

veraB-9

On a related note.

With the current implementation, a regular user (who should not worry about any translations) sees "WPML Translator Settings" within his/her profile (attachment). To reduce the unnecessary interfaces for a regular user, our developer attempted to hide this field for regular users. However, it seems that there is no specific class assigned to this field, and addressing 'user-language-wrap' class would remove the language switch as well (not the intended result, obviously).

We'll appreciate any suggestions (I understand that this looks like a feature request, but the cleaner / non-confusing interface for a regular user who is not engaged in the internal working of the site will be appreciated by other clients as well).

Thank you!

aihealthpath team

February 26, 2025 at 1:11 pm #16751067

veraB-9

the screenshot mentioned a minute ago

User_Transl_Settings.jpeg
February 26, 2025 at 4:20 pm #16752183

Osama Mersal
Supporter

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

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

Hi,

I consulted our 2nd tier support team regarding this, and I'll update you as soon as they reply.

Best regards,
Osama

February 27, 2025 at 10:23 am #16755145

Osama Mersal
Supporter

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

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

Hi,

Thanks for your patience. You can use the following function in the functions.php to hide those options.

/**
 * Remove WPML options from the user profile page for non-admins
 */
if ( ! current_user_can( 'manage_options' ) ) {
    remove_action( 'personal_options', 'wpml_show_user_options' );
}

Best regards,
Osama