0

I would like to change the logged in user's language (if someone is logged in) when they change the language in front-end.

I'm using the WPML Multilingual CMS plugin in my Wordpress website.

I've tried to add this code in my custom plugin:

add_action('wpml_language_has_switched', 'change_user_language_in_database');

function change_user_language_in_database()
{
  die("test function");
}

The problem is that this function is always triggered. Also when the language isn't switched.

The version of WPML Multilingual CMS plugin is 4.2.7.1.

What am I doing wrong?

3
  • Try maybe using a filter? Haven't had many clients using this plugin. According to docs there is a wpml_setting that stores different settings as well as their values. wpml.org/wpml-hook/wpml_setting Commented Sep 16, 2019 at 19:55
  • @YaroslavIshanov, I don't understand what you mean. I'm trying to check if the language in front-end is changed.
    – nielsv
    Commented Sep 17, 2019 at 9:54
  • Did you manage to find a solution? I am also seeing that wpml_language_has_switched is triggering multiple times even on page load, instead of when the language actually changes in front-end.
    – dominotrix
    Commented Sep 3 at 11:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.