Support

Account

Home Forums General Issues Automatically fetch translations for user meta with Polylang

Unread

Automatically fetch translations for user meta with Polylang

  • Hi!

    Just want to share this snippet I created today as an attempt to solve an issue with a client site.

    They have lots of user meta added via ACF and some time after launch now wanted multilanguage support. We use Polylang for this which works nicely with ACF except for User meta.

    I duplicated all the field groups for users and added _languageslug to the end of each name so in each user profile there would be two sets (one for each language) of the ACF fields. In our case Swedish and English.

    So a single field would exist as “user_phonenumber” and “user_phonenumber_sv” (the swedish version).

    I did not want to go through ALL the theme files manually and add in checks for the language and change each get_field or the_field call manually so I tinkered with ACFs hooks and came up with this gist:

    https://gist.github.com/jonathan-dejong/26ec2bf8bf25890c2365

    Cant use ACFs get_field for some reason (it sends the site into an 502 error) hence the elaborate use of get_user_meta.

    Please let me know if anyone finds an issue with this.. We use it in production and so far it’s been working nicely.

Viewing 1 post (of 1 total)

The topic ‘Automatically fetch translations for user meta with Polylang’ is closed to new replies.