0
votes

I'm working on a website, which is multilingual. We're using Polylang and the ACF custom fields plugin.

Works fine in general, the issue is with the ACF Option pages. The option pages are translated also in different languages.

The content we are taking from there is being displayed according to translation - in english on the english version of a page, french on the french etc.

The problem: We have a contact us form, where we take the recipients email address from the ACF option pages. (We want to send it to a different recepient when its a different language.)

Here it always takes the email address from the default language option page and I don't understand why.

We are taking the email recipient for the ajax call with get field command, like on pages displaying content:

 get_field('service_email', 'option' );

Anyone got an idea what could cause this? Or where to look?

1

1 Answers

1
votes

In the end we found the solution. It took a bit of digging, but I hope this helps if anyone encounters the same issue.

We needed to add the following setup in the functions.php of our theme to have the ACF options pages also translated for the each language:

// Translating Options Page Compatibility
// add filter with the path to your acf installation
add_filter('acf/settings/default_language', 'my_settings_default_language');
add_filter('acf/settings/current_language', 'my_settings_current_language');

function my_settings_default_language( $lang ) {
if($lang == "") {
    $lang = pll_default_language(); // pll_ is a polylang function
  }
  return $lang;
}

function jfrog_settings_current_language( $lang ) {
   $lang = pll_current_language();
   return $lang;
}

Side Note: We're using a theme installed version of ACF.

hope this helps, Cheers