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 5 replies, has 2 voices.

Last updated by Mohamed Sayed 1 year, 1 month ago.

Assisted by: Mohamed Sayed.

Author Posts
March 13, 2024 at 1:39 pm #15404256

katrinaC-2

We're having issues getting ACF and WPML to play nicely together. I finally got most of the fields I want to be available for translation but after the translation is complete the ACF fields are not found. (see screenshots)

FYI Our site is atypical. We're using ACF Pro but we're defining our Field Groups with StoutLogicAcfBuilder (hidden link) so the field configuration is closer to defining ACF using PHP than using the UI. i.e.

// Main Content Blocks
    ->addAccordion('Main Content', ['wpml_cf_preferences' => 1])
        ->addFlexibleContent('content_blocks', ['label' => 'Content Blocks', 'button_label' => 'Add Content Block', 'wpml_cf_preferences' => 1])
            ->addLayout(get_field_partial('blocks.content', [
                'remove' => [
                    'constrain_width',
                ],
            ]))

To work around this I created an ACF Field Group using the UI admin then followed the pattern in the PHP ACF export in our field definitions.

I can't find any documentation or help articles suggesting why ACF fields wouldn't be available but I suspect my `wpml_cf_preferences` values are off somewhere.

March 13, 2024 at 6:24 pm #15405774

Mohamed Sayed

Hi,

I'm consulting our 2nd tier supporters and will update you once I get their reply.

March 14, 2024 at 9:17 am #15408378

Mohamed Sayed

Thanks for your patience!

Our 2nd tier supporters suggest saving the field group configurations as JSON files instead of registering the fields directly in PHP.

Please check this errata page: https://wpml.org/errata/advanced-custom-fields-local-fields-translation-preference-issue-for-php-registered-system-fields/

March 14, 2024 at 4:06 pm #15411434

katrinaC-2

Unfortunately saving the field groups as JSON isn't a viable option here. Since we're using ACF Pro with StoutLogic/acf-builder our field groups are created using PHP and therefore don't even show up in the ACF Pro and/or ACF Pro Extended admin to change their creation methods. Also we have approximately 40 different field groups.

We're reached out to the developer(s) on StoutLogic/acf-builder to see if there is a way to save out as JSON or import into the ACF UI but I am not confident there will be a solution.

I know this was reported relatively recently from the other post on I believe the 4th but is there a fix planned for this bug, knowing that it's probably a relatively rare occurrence?

Do you have any other thoughts or recommendations on how to work with the PHP definitions?

Can you shed any additional light on the various settings for `acfml_field_group_mode` as I can't find any documentation on the differences there.

Thanks for all of your help.

March 15, 2024 at 12:45 am #15412572

Mohamed Sayed

I shared your reply with our developers and will let you know once I get their feedback.

Kind regards,
Mohamed

March 19, 2024 at 8:32 am #15424559

Mohamed Sayed

Hi,

Our developers suggest using the wpml-config.xml file https://wpml.org/documentation/support/language-configuration-files/custom-fields-translation-options/ to set the translation preferences of system fields. You can set fields as system fields when starting with an underscore.

For example, a Flexible field contain a text field and you have set it to Translate. Then the corresponding system field should be set to Copy e.g.
Flexible Content Test_0_simple_txt is set to translate.
_Flexible Content Test_0_simple_txt should be set to copy.

Where 0 is dynamic. You can set this field to copy manually or use PHP to generate an XML file in the theme having field names _Flexible Content Test_0_simple_txt, _Flexible Content Test_1_simple_txt and so on.

Regarding acfml_field_group_mode there are three different values:
1. translation - means "same fields across the language"
2. localization - means "different fields across the language".
3. advanced - means expert mode.

These modes are defined here: https://wpml.org/compatibility/2023/03/acfml-2-0-easy-multilingual-setup-and-translation/

And the recommended translation preferences are defined here: https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/recommended-custom-fields-translation-preferences-for-acf-and-wpml/