Skip Navigation

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

Last updated by Tim 5 years ago.

Assigned support staff: Sumit.

Author Posts
August 20, 2015 at 10:42 pm #683749


I am trying to:
Keep the user select language on Login.

URL of (my) website where problem appears:
on a dev site, can't be accessed externally at this time.

Basically, I'm trying to set the language before ICL_LANGUAGE_CODE gets set. I have seen other form post about how ICL_LANGUAGE_CODE is set when the obj starts up, but it has to get that initial language from somewhere, so how can I set that?

This code suggested here does not work:

And here he shows that ICL_LANGUAGE_CODE is set like :

Maybe I could define ICL_LANGUAGE_CODE in a hook before the WPML plugin loads, but I can't seem to find which hook that would be.

I've even filtered in a new hidden input on login form, this has the lang value set, and I pick that up in this hook here, to try to set the define( 'ICL_LANGUAGE_CODE') before anything else:

function show_session ()
	$lang = $_POST['lang'];
	define( 'ICL_LANGUAGE_CODE',  $lang );

But no luck,

August 21, 2015 at 12:02 pm #684148


Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)


#1 You are using old version of WPML and all its addon plugins.
If you are NOT an ICanLocalize client then you can upgrade to WPML 3.2.6 and all its addon plugins to their latest version listed here
Please follow this article and watch the video carefully before updating

#2 I am not exactly sure because custom work is beyond our support but I can suggest you wpml_current_language filter which is used by other themes and plugins to determined the current language code.
You can add a hook on "registered_taxonomy" like

add_filter('wpml_current_language', 'return_current_lang', 999); //set 999 to overwrite all results

Along with defining "ICL_LANGUAGE_CODE"

And let me know does it help?


August 24, 2015 at 6:04 pm #686107


Hi Sumit -

Thanks for the suggestion, but that unfortunately didn't work.

I ended up solving the issue via login redirects. So if the user is in Spanish, then they login, they are redirected to the es/dashboard page - and if they are in english, then just redirected to the /dashboard page.