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?
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
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.
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.