• Resolved herrschuessler

    (@herrschuessler)


    We’re using WPML for translations and the WPML-Add-On Advanced Custom Fields Multilingual (ACFML) to translate ACF fields. ACFML adds the attribute wpml_cf_preferences to the local JSON field definitions. When Advanced Custom Fields: Extended is active, we get the following PHP notices, allthough our ACF / WMPL-Setup is correct:

    
    Notice: Undefined index: wpml_cf_preferences in /wp-content/plugins/acfml/classes/class-wpml-acf-field-settings.php on line 152
    
    Notice: Undefined index: wpml_cf_preferences in /wp-content/plugins/acfml/classes/class-wpml-acf-field-settings.php on line 152
    

    Has this plugin been tested against WPML and ACFML?

    Cheers
    Christoph

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    It looks like the problem come from the ACFML plugin. In fact you’ll see those PHP notices, without ACF Extended, when trying to register local PHP field groups with a Flexible Content.

    Here is a code example that will trigger those notices on a blank WordPress 5.8 install, with ACF Pro 5.10.2 + WPML 4.4.12 + ACFML 1.9.0:

    add_action('acf/init', 'my_acf_init');
    function my_acf_init(){
        
        acf_add_local_field_group(array(
            'key' => 'group_6138ad2c18c60',
            'title' => 'Flexible Content',
            'fields' => array(
                array(
                    'key' => 'field_6138ad2f4fb45',
                    'label' => 'Flexible Content',
                    'name' => 'flexible_content',
                    'type' => 'flexible_content',
                    'instructions' => '',
                    'required' => 0,
                    'conditional_logic' => 0,
                    'wrapper' => array(
                        'width' => '',
                        'class' => '',
                        'id' => '',
                    ),
                    'layouts' => array(
                        'layout_6138ad3456061' => array(
                            'key' => 'layout_6138ad3456061',
                            'name' => 'layout',
                            'label' => 'layout',
                            'display' => 'block',
                            'sub_fields' => array(
                                array(
                                    'key' => 'field_6138ad374fb46',
                                    'label' => 'Test',
                                    'name' => 'test',
                                    'type' => 'text',
                                    'instructions' => '',
                                    'required' => 0,
                                    'conditional_logic' => 0,
                                    'wrapper' => array(
                                        'width' => '',
                                        'class' => '',
                                        'id' => '',
                                    ),
                                    'default_value' => '',
                                    'placeholder' => '',
                                    'prepend' => '',
                                    'append' => '',
                                    'maxlength' => '',
                                ),
                            ),
                            'min' => '',
                            'max' => '',
                        ),
                    ),
                    'button_label' => 'Add Row',
                    'min' => '',
                    'max' => '',
                ),
            ),
            'location' => array(
                array(
                    array(
                        'param' => 'post_type',
                        'operator' => '==',
                        'value' => 'post',
                    ),
                ),
            ),
            'menu_order' => 0,
            'position' => 'normal',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => true,
            'description' => '',
        ));
        
    }
    

    This code will register a simple local Field Group with a Flexible Content using the acf/init hook recommended by ACF in the official documentation (section: “Add within an action”).

    Add within an action
    The functions above can be used in the root of the functions.php file or within the acf/init action. This action was added in ACF v5.2.7 and is recommended.

    The benefit of using this action is that the function is guaranteed to exist, and won’t run unless ACF is active.

    It looks like WPML & ACFML have troubles to handle local PHP Flexible Content. I would suggest to open a bug report on their support platform.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter herrschuessler

    (@herrschuessler)

    Hi @hwk-fr, thanks for your thorough answer. As I’m not using local PHP, only local JSON, and the issue only exists when your plugin is active, I’m still no sure if it might not be related to ACFE – what do you think?

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Yes, it is because ACF Extended register a local Field Group with a Flexible Content (for the ACFE Form module notably).

    Have a nice day!

    Regards.

    Thread Starter herrschuessler

    (@herrschuessler)

    That explains it, thanks! I’ll try deactivating the form module and see if that helps.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Well that would be a workaround, but that wouldn’t fix the issue. I would really recommend to open a ticket on the WPML support platform, as this issue affect any ACF Pro installation that use local Field Group with Flexible Content, which is pretty common.

    I don’t have access to their support platform, as I’m not using WPML anymore. If you could do it, it would help the ACF community ??

    Regards.

    Just wanted to let you guys know in this thread as well that this should be fixed in ACFML 1.9.1 which should be out any day now.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘This plugin combined with WPML (ACFML) throws PHP notice’ is closed to new replies.