Skip Navigation

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

Problem: ICL_LANGUAGE_CODE is not working with Complianz plugin

Solution: It works after using *wpml_current_language* hook instead of ICL_LANGUAGE_CODE. Please check the sample.

$my_current_lang = apply_filters( 'wpml_current_language', NULL );
 
if($my_current_lang=='pt-br'){
//Custom code
}

Relevant Documentation: https://wpml.org/wpml-hook/wpml_current_language/

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 kellyL-9 1 year, 10 months ago.

Assisted by: Bigul.

Author Posts
June 6, 2022 at 3:39 pm #11397471

kellyL-9

While trying some alternative solutions to the problem above, I was experimenting in php with ICL_LANGUAGE_CODE and the Complianz add_filter. It was not working. I was putting it in my custom plugin, but by the time the custom plugin was executed, I guess the ICL_LANGUAGE_CODE was probably not set up yet. So do you know how is the right way to check for that variable in my custom plugin?

I was just trying to do:

if(ICL_LANGUAGE_CODE == 'pt-br'){
//complianz add_filter(...);
}

Thank you

June 6, 2022 at 3:53 pm #11397569

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

Please try with the *wpml_current_language* hook and make sure it is working or not.

Please refer to the following documentation and sample code for more details.

https://wpml.org/wpml-hook/wpml_current_language/

$my_current_lang = apply_filters( 'wpml_current_language', NULL );

if($my_current_lang=='pt-br'){
//Custom code
}

--
Thanks!

Bigul

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.