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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Bigul 1 year, 10 months ago.

Assisted by: Bigul.

Author Posts
July 20, 2023 at 3:31 pm #14074011

George Meisenberger

Hi,

we have a multisite setup where we want to disable the available languages on a subsite programmatically.

per my knowledge, there is no function or hook available, so I checked the DB and found the wp_99_icl_languages table. we set the languages on inactive there. Additionally we adjusted the option_value "icl_sitepress_settings" in the wp_99_options table. But the languages are still shown/available.

Is there a way to programmatically disable languages?

BR

July 21, 2023 at 1:53 pm #14080355

Bigul
WPML Supporter since 01/2013

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.

We are not recommending disabling the language via code. Because there may be a chance of conflicts if we edit the option value "icl_sitepress_settings". So the best option is to hide the language from WPML>>Languages>>Hide Languages. Refer to the following doc for more details

https://wpml.org/documentation/getting-started-guide/language-setup/hiding-languages-on-the-front-end/

Maybe you have to clear the WPML caches, after updating the wp_99_icl_languages table & "icl_sitepress_settings" option values. It works for us after trying the following code in the functions.php file of the theme.

global $wpdb;
$wpdb->query("UPDATE `wp_icl_languages` SET `active` = '0' WHERE `code` = 'fr'");
icl_cache_clear();
$cache_directory = new WPML_Cache_Directory( new WPML_WP_API() );
$cache_directory->remove();

But please note that we have limitations here because of customization and we are not recommending this due to the high risk for errors.

--
Thanks!

Bigul

July 25, 2023 at 9:25 am #14094621

George Meisenberger

thanks - that worked like a charm!