We have a client with ACF PRO. When he created his site, he put in the field name Files and File for file upload.
This was working before, but for a while it doesn't work anymore.
Have you changed anything in the code that might affect this?
We would like to find a solution without changing the 300 products and several attached files.
Link to a page where the issue can be seen: hidden link
I expected to see:
Like french site : hidden link
Instead, I got:
We spoke with ACF and he verified the code and told us that :
I am afraid this is a translation-related issue and from our end, we are not able to confirm how the WPML plugin handles translation therefore we are not in a better position to conclusively advise on this.
Due to the huge and complex changes in the WPML plugin, we may not be well equipped to advise on this translation-related issue. I would recommend reaching out to WPML support regarding the issue as their plugin is used in handling translation. Hopefully, they will shed some light on the same :).
Please note that our support is limited in scope to the basic usage of the ACF plugin and we don't offer any translation-related support to our customers.
Apologies for not being able to help and please let me know if there's anything else I can help you with.
Thank you for contacting us, and apologies for the delayed response due to weekends and high queues.
Would you please elaborate more on what issue you are having with the ACF file/file upload field translation? I tried checking the links you shared, but it looks like it is password protected and requires a login to check.
Please share the site credentials for me to check the site. I have enabled the private reply for you to share the credentials safely.
I can see the issue now. Please note that since the issue involves custom code, our support might be limited. However, I will try my best to help you.
You have translated the field group and have different names for the custom fields. I think the issue is coming from line 7 in the code you shared above. I see you have
...
if ( secrepro_get_current_lang() !== 'fr' ) {
...
But the function secrepro_get_current_lang is not appropriately defined in the code you shared. Please note the proper hook to use to get the current language with WPML is wpml_current_language, as explained in the next link:
I don't believe this code is the cause of this problem. To demonstrate that this isn't the case, I edit the code to show you the result. We already this this idea before contact you.
I edited your English Field group and set the internal name of the fields the same as in the french, and translated only the field labels. This seems to fix the issue now.
This should also simplify your code as multiple field names for multiple languages are now not required. I also edited your functions.php file and removed the if statement to change the field names based on the current language.
Since I noticed you are editing the translations manually/duplicating the pages, I have edited the field group and set all fields to not translate. You can change that if you want.
Please check it on the site and let me know how it goes for you.
When you say: "This was working before, but for a while, it doesn't work anymore." do you mean when the field's name was set as files, file, and name for the English field group, it was working before?
- Have you changed anything in the code that might affect this?
No, I didn't change in the code anything related to this. I only changed the English field group field names to the same as french from the field group settings and removed the if('fr' !== $my_current_lang){... part in the code. But I have reverted it since this solution might not work for you if you have already entered the product data in the old field name.
- Can you tell us how to change the name of all problematic fields related to the product and keep the value already entered?
This can only be done using third-party plugins like WP All Export/Wp All Export. You can export the product data, including custom fields, and import them again to correct the field name. Please refer to the following documents for more details.
It is logical to set the same field name for both translations and use only different field labels, which also solves the issue. But if you want to keep using different field names/identifiers, to troubleshoot the issue further and find if this is a WPML issue or not, I have created a sandbox site for you, which you can log in to using the following link:
hidden link
Please login to the site, set up WPML and your plugins, themes/code, and let me know. I will try my best to help you, but at some point, you might need to contact ACF support or work with a WPML contractor as this involves custom coding and ACF.
Regards,
Subash
The topic ‘[Closed] ACF PRO field name Files and File for file upload doesn't work anymore’ is closed to new replies.