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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Bobby 1 year ago.

Assisted by: Bobby.

Author Posts
January 22, 2024 at 9:26 pm

jean-francoisS-2

I have a website with ACF + WPML installed. When I save posts that have a translation made with the "Duplicate" button from WPML, I get this error: PHP Fatal error: Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string, array given in /var/web/site/public_html/wp-content/plugins/wpml-string-translation/classes/filters/strings-filter/class-wpml-register-string-filter.php:205

January 22, 2024 at 10:30 pm
January 22, 2024 at 11:32 pm #15213812

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hello,

I am working on reproducing the issue on the staging site.

- I have gone to pages and added a new page called WPML test
hidden link

- Added an ACF for textre image and published

- Switched to EN and added content then published

I got no error and the content I added remains after a reloadd.

Then I tried again but this time after adding the ACF twice, but I got the same results.

Am I missing a step? Please review and update me.

January 23, 2024 at 2:36 pm #15217724

jean-francoisS-2

Hello,

When creating the page in English, we want to duplicate the page (and not only add a translation).

When doing so (I did a test with the page you've created), the second time a block is use (for this example, I've used Membres), the fields are empty when reloading the admin.

You can check with WPML TEST and WPML TEST EN (which are both fr and en respectively).

I suspect the problem is caused with the repeater and WPML is not capable of putting a unique identifier to both blocks.

Sorry for the delay, we seem to be on different timezone 🙂

January 23, 2024 at 8:46 pm #15218840

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for updating me!

I was able to see the issue with the membres block.

However, I am not able to reproduce with a new acf block added through ACF field groups, for example the WPML block is added to the membres block and it works OK.

How are the fields Ancre and Titre added?

I wonder if this has possibly something to do with code configuration, are these added using custom code?

January 23, 2024 at 9:02 pm #15218918

jean-francoisS-2

Ancre and Titre are Clones that we add on each block, because we use them has partial in our code.

You think it's because we use clones ?

January 23, 2024 at 10:46 pm #15219146

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

It is hard to tell, the best way would be to review the code used to add the acf block, at the moment the issue is pointing toward the custom code as this issue does not happen with standard ACF fields.

Please share this with me to further review and how you would add this block if you had to re produce the issue in a clean environment

January 24, 2024 at 2:06 pm #15222205

jean-francoisS-2

Here's how we register our blocks :

<?php
require_once(get_template_directory() . '/functions/block-settings/shifted-text.php');
require_once(get_template_directory() . '/functions/block-settings/preview-events.php');
require_once(get_template_directory() . '/functions/block-settings/preview-personas.php');
require_once(get_template_directory() . '/functions/block-settings/cta.php');
require_once(get_template_directory() . '/functions/block-settings/preview-what-to-do.php');
require_once(get_template_directory() . '/functions/block-settings/preview-news.php');
require_once(get_template_directory() . '/functions/block-settings/cta-newsletter.php');
require_once(get_template_directory() . '/functions/block-settings/wysiwyg.php');
require_once(get_template_directory() . '/functions/block-settings/gallery.php');
require_once(get_template_directory() . '/functions/block-settings/text-interview.php');
require_once(get_template_directory() . '/functions/block-settings/preview-map.php');
require_once(get_template_directory() . '/functions/block-settings/text-image.php');
require_once(get_template_directory() . '/functions/block-settings/text-image-two-cols.php');
require_once(get_template_directory() . '/functions/block-settings/marquee.php');
require_once(get_template_directory() . '/functions/block-settings/related-posts.php');
require_once(get_template_directory() . '/functions/block-settings/logo-cloud.php');
require_once(get_template_directory() . '/functions/block-settings/faq.php');
require_once(get_template_directory() . '/functions/block-settings/members.php');
require_once(get_template_directory() . '/functions/block-settings/carrousel.php');
require_once(get_template_directory() . '/functions/block-settings/stats.php');
require_once(get_template_directory() . '/functions/block-settings/form.php');
require_once(get_template_directory() . '/functions/block-settings/video.php');
require_once(get_template_directory() . '/functions/block-settings/blockquote.php');

//Register the block with ACF
function treize_register_block($settings)
{
if (class_exists('ACF')) {
acf_register_block_type($settings);
}
}

//Create Block categories
add_filter('block_categories_all', function ($categories) {
// TODO: Adjust depending on how your fields need to be categorized
$categories[] = array(
'slug' => 'hero',
'title' => 'En-t�te'
);

$categories[] = array(
'slug' => 'form',
'title' => 'Formulaire'
);

$categories[] = array(
'slug' => 'display',
'title' => 'Texte'
);

$categories[] = array(
'slug' => 'text-image',
'title' => 'Texte et Images'
);

return $categories;
});

//Allowed block to be used
function treize_allowed_block_types()
{
return array(
'acf/carrousel',
'acf/cta-newsletter',
'acf/cta',
'acf/faq',
'acf/form',
'acf/gallery',
'acf/logo-cloud',
'acf/marquee',
'acf/members',
'acf/preview-events',
'acf/preview-map',
'acf/preview-personas',
'acf/preview-what-to-do',
'acf/preview-news',
'acf/related-posts',
'acf/shifted-text',
'acf/stats',
'acf/text-image-two-cols',
'acf/text-image',
'acf/text-interview',
'acf/wysiwyg',
'acf/video',
'acf/blockquote',
);
}
add_filter('allowed_block_types_all', 'treize_allowed_block_types');

Then we create an inactive block which will be use as an anchor tag and if the user wants to show the block or not.

Finally, we use this acf has a clone in other blocks to not redo the same acf over and over again.

After this, we only add blocks with the page builder of wordpress.

The thing I don't understand is that we don't use custom code for the ACF, we use the standard Clone field inside ACF.

Screenshot 2024-01-24 at 09.02.57.png
Screenshot 2024-01-24 at 09.01.21.png
January 24, 2024 at 5:47 pm #15223211

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you very much for sharing this information!

I have discussed this with our team and it looks like there is a known issue that would cause the behavior you are experiencing.

Please review the following documentation, try the workaround, and let me know your results
https://wpml.org/errata/acf-block-clone-field-value-lost-when-same-block-added-twice-in-a-post/

The topic ‘[Closed] Uncaught TypeError: strlen()’ is closed to new replies.