[Resolved] critical error - cannot add new language
This thread is resolved. Here is a description of the problem and solution.
Problem:
I am trying to change/add the language code in the development site but I faced the following error:
PHP Fatal error: Uncaught Error: Call to undefined method WP_Error::filter() in .../wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:202
Solution:
The issue happened because the site's URL was changed, in this case, WPML will detect the change and show a banner asking if the site was moved/Copied to the new URL.
Kindly select if the site was moved to the current URL or if this is a copy of the main site then try again to add the 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.
No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.
Once a language has been created, it is not possible on WPML's interface to change the language. Can you please explain to us how did you change the language code?
Apologies for the confusion - what I mean is that I tried to add new language based on the first screenshot I provided, I added it that way but when I click 'save' it appears to have a critical error when adding it. And the result when clicking 'save' is the second screenshot I provided.
Please go to WPML > Support > Troubleshooting page, then click the following:
- Clear the Cache in WPML
- Remove ghost entries from the translation tables
- Fix element_type collation
- Fix WPML table collation
- Set language information
- Fix post type assignment for translations
❌ Please make sure that you have a full database and website backup before trying the above ❌
If that didn't help, please try the following steps to install a fresh copy of the WPML plugin:
- Create a full database and website backup
- Access your site's root folder via FTP or cPanel
- Delete the current WPML plugin folder "sitepress-multilingual-cms" from the /wp-content/plugins/ directory
- Download a fresh copy from: https://wpml.org/account/downloads/
- Install it again from Plugins > Add new
- Activate it
Already done that steps/procedure you've said above but still having critical/fatal error when adding custom language in WPML -> Languages -> Edit languages -> Add languages. I follow this documentation https://wpml.org/documentation/getting-started-guide/language-setup/editing-wpmls-languages-table/ on adding custom language. But still having errors when clicking 'save'. Can you please help me with this?
I hope this helps - this are the screenshot we've found and as well the result after following the steps/procedure you've advised. Still the error occurred. Please see the attached screenshot below.
Could you please clear the cache then disable any Minify/Caching plugins temporarily and check if the issue is resolved?
If you still see the same issue, kindly check again in a minimal environment by following these steps:
- Deactivate all the plugins that are not related to WPML.
- Switch for a moment to a WordPress default theme like Twenty Twenty-one.
- If the issue is gone, activate one by one to see with which one there is an interaction issue.
❌ Please backup your database and website before performing the above test ❌
I already did the steps above that you've advised but still having issues/errors with adding custom language on WPML -> Languages -> Edit languages -> Add languages. The error is still the same and I cannot add a custom language. Please see attached screenshots below.
I would need to request temporary access (WP-Admin and FTP) so I can investigate this issue further.
– preferably to a test site where the problem has been replicated if possible –
Your next answer will be private, which means only you and I have access to it.
❌ Please backup your database and website before providing us with access details ❌
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme and to change configurations on the site if needed. This is also a reason the backup is critical.
✙ I would also need your permission to take a local copy of your site to debug the issue without affecting your live site.