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.
This topic contains 4 replies, has 0 voices.
Last updated by 1 month, 2 weeks ago.
Assisted by: Osama Mersal.