WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Custom field values override other translation values (10 posts)

  1. kuyabiye
    Member
    Posted 1 year ago #

    The plugin works great, i have only an issue about it. I am using the plugin "advanced custom fields". i have a checkbox field and i have 3 translations. for example when i change the value of checkbox in english translation, the value of the checkboxs are in other translations becomes unchecked. so it is not possible to assign the same value for all checkboxes. i tried it in other types of custom fields, it works like that too.

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    There is something wrong with the synchronization of custom fields. I will check that. Waiting for this, you can go in Polylang settings and uncheck the synchronization of custom fields. this should solve your issue.

  3. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    OK I found the reason for the conflict with acf. Polylang synchronizes custom fields before ACF saves them.

    Waiting for a new release, you can edit the file polylang/include/admin-filters.php at line 59 (v1.0.1) and replace:

    add_action('save_post', array(&$this, 'save_post'), 10, 2);

    by

    add_action('save_post', array(&$this, 'save_post'), 25, 2); // priority 25 to come after acf
  4. kuyabiye
    Member
    Posted 1 year ago #

    it works, thanks!

  5. imagevo
    Member
    Posted 1 year ago #

    Hi,
    Polylang is really great, easy to use and powerful!
    I had an issue with custom fields translations overwriting all other translations.
    I unchecked the synchronization of custom fields in the admin panel and now it works great!

  6. miguelcortereal
    Member
    Posted 11 months ago #

    I have this same issue too, but only partially.

    I could solve the overriding issue and maintaining the synchronization by including at wpml-config.xml file each custom field defining a translation action.

    Polylang by default (judging by the behaviour) seems to take copy action.

    All those fields come from Types plugin that I'm using.

    <custom-fields>
     	<custom-field action="translate">cf1</custom-field>
    	<custom-field action="translate">cf2</custom-field>
    	<custom-field action="translate">cf3</custom-field>
    </custom-fields>

    On the other hand I'm using Attachments plugin that handles images upload with several custom fields for descripton.

    These custom fields are organized in an array within a row at wp_postmeta table.

    For such case, the lines structure of the wpml-config.xml file for custom fields should be diferent than the one pointed above.

    It would have to be something like:

    <custom-fields>
          <custom-fields-group="name_of_key">
                 <custom-field action="translate">cf1</custom-field>
                 <custom-field action="translate">cf2</custom-field>
          </custom-fields-group="name_of_key">
    </custom-fields>

    I don't find anywhere mentioned this kind of structure for custom fields the same way it exists for <admin-texts>.

    If my thoughts on this went on the right direction, I'm disabling custom fields synchronization too.

  7. Chouby
    Member
    Plugin Author

    Posted 11 months ago #

    Yes by default Polylang copies all public custom fields (the synchronization is optional). Hidden custom fields are not copied (except page template and featured image which are in fact hidden custom fields).

    To modify this comportment, one has to code and use the 'pll_copy_post_metas' filter or use a wpml-config.xml file as you do.
    Actions "translate" and "copy" have the same comportment in Polylang (the custom fields are copied, not synchronized even if the synchronization option is active) as I don't understand what difference WPML makes between the two actions. The action "ignore" just ignores the custom field which is not copied.

    The "custom-fields-group" section is not documented by WPML. If it exists, then it is not implemented in Polylang. For Polylang an array of custom fields is a unique custom field.

  8. miguelcortereal
    Member
    Posted 11 months ago #

    The difference between copy and translate according what I've experienced:

    Copy - Populates the field value with the last saved version in every correspondent language versions.

    Useful for numeric fields, with just one insertion in any language you get at once all language versions populated with that value.

    Translation - When editing the field pulls the last saved version if empty, when saving it doesn't populate the value at the rest of correspondent language versions as copy does.

    Useful when creating the translations of a post, it pre poulates the field with the original language value.

  9. Chouby
    Member
    Plugin Author

    Posted 11 months ago #

    So if I well understand:
    Copy: is in fact what I call synchronization (all values are kept the same in all translations)
    Translate: is the default comportment of Polylang when custom field synchronization is deactivated.
    That make sense. I should update Polylang to reflect this.

  10. miguelcortereal
    Member
    Posted 11 months ago #

    And maybe add beside each synchronization checkbox at Polylang settings 1 or 2 note lines describing what it does and how behaves.

    It would turn the configuration easier for users.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.