• Resolved arekzw

    (@arekzw)


    Hello!

    I have the following situation:
    Xpl — relations field —> Ypl

    I am using WPML, so I immediately have the relation:
    Xeng — relations field —-> Yeng (“copy” setting in WPML)

    I installed ACFE to achieve bidirectional relation.
    Bidirectional works for primary language:
    Xpl <— relations field — Ypl

    But relationships in a different language version are not synchronized:
    Xeng <— relations field —- Yeng

    Anyone have an idea why this might be happening?`

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

    (@hwk-fr)

    Hello,

    Thanks for the feedback, and sorry for the late answer, I’m kinda busy with the upcoming patch lately.

    I tested the native ACF Relationship (without bidirection) from a Post > Page, and when I translate the Post with WPML to an another language, it doesn’t translate the Relationship value to the related Page new language. Even when using “Copy from original post” setting. Here is the video of my test.

    This is because WPML use different IDs for post translations, and ACF can’t guess it. So the user has to set the relationship himself when creating a new language. ACF Extended rely heavily on the ACF mechanics for the Relationship field, so unfortunately the logic is the same.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter arekzw

    (@arekzw)

    Hello,
    Thank you for answer.

    Your test workflow it’s not correct.

    “Copy from original post” copy only content, without fields.

    To achieve step 2 (Xeng — relations field —-> Yeng (“copy” setting in WPML)) you must set “copy” option in WPML -> Settings -> Custom field translations -> Relation field.

    Then the connection of automatic connection to another language version will work. And thanks to your plugin, a two-way relationship also will work.

    But last case, the bidirectional relationship between the post in the second language version will not work.

    Regards!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the details, and sorry for the late answer, I was kinda busy with the latest patch lately.

    I managed to reproduce the case. The addon you are referring to is ACFML. With that addon, and the “Copy Translation” setting enabled in the Relationship Field setting, it will copy the data to the translated post with the translated Post ID.

    I took a look at the code of the addon, and there is a problem which prevent any third party plugin such as ACF Extended to apply new features.

    In fact, ACFML update the post meta on the translated post using the native wp update_post_meta() function, which means ACF (and other ACF-related plugins) aren’t aware of that update.

    In file \acfml\classes\class-wpml-acf-worker.php:45

    update_post_meta( $post_id_to, $meta_key, $meta_value_converted, $meta_value );
    

    In order to follow the ACF coding best practice, ACML should use acf_update_value() to update the post meta. So their process trigger the native ACF update logic, and subsequent hooks such as acf/update_value, which is then used by third party plugins like ACF Extended.

    Like this:

    acf_update_value( $meta_value_converted, $post_id_to, $field );
    

    Unfortunately I can’t really do much here, since update_post_meta() is such a wide-range function outside of ACF scope. Also, there is no hook available in that part of their code which would let me workaround the issue and add some compatibility fix.

    I would recommend to contact the WPML support to report them that enhancement. This will be for the best for ACFML, as it will make the addon more ACF-friendly globally.

    Here is a video showing the fix applied.

    As a side note, outside of ACF Extended, there are also some other issues in the ACFML code logic that I noticed. For example, the ACFML “copy” feature for the Relationship Field doesn’t work if the Relationship is a sub field of a Group Field.

    This is because they do a simple check on the meta key acf_get_field( $meta_key ), while the meta key can be composed with the parent Group Field. But this is an another issue.

    Here is a video showing the issue with ACF + WPML + ACFML only (ACF Extended is disabled).

    I hope it’s now more clear.

    Have a nice day!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bidirectional Fields and WPML’ is closed to new replies.