Skip Navigation

Open

Topic Tags: Compatibility

Overview of the issue

When using ACF – Advanced Custom Fields with the ACFML plugin, if a Clone field is set to Copy Once, the field values cannot be retrieved in the original language on the front end. The issue occurs when the field group containing the Clone field is set to Different fields across languages or when the field is manually set to Copy Once in Expert mode.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open the …wp-content/plugins/acfml/classes/class-wpml-acf-custom-fields-sync.php file.
  • Look for line 42.
  • Replace:
    public function clean_empty_values_for_copy_once_field( $value, $post_id, $field ) {
    	if ( '' === $value
    		&& ! $this->value_has_been_emptied( $field )
    		&& isset( $field['wpml_cf_preferences'] )
    		&& WPML_COPY_ONCE_CUSTOM_FIELD === $field['wpml_cf_preferences']
    		&& ! $this->isFieldType( $field, 'group' )
    	) {
    		$value = null;
    	}
    	return $value;
    }
    
  • With:
    // WPML Workaround for compsupp-7767
    public function clean_empty_values_for_copy_once_field( $value, $post_id, $field ) {
    	if ( '' === $value
    		&& ! $this->value_has_been_emptied( $field )
    		&& isset( $field['wpml_cf_preferences'] )
    		&& WPML_COPY_ONCE_CUSTOM_FIELD === $field['wpml_cf_preferences']
    		&& ! $this->isFieldType( $field, 'group' )
    		&& ! $this->isFieldType( $field, 'clone' )
    	) {
    		$value = null;
    	}
    	return $value;
    }
    

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>