Home › Forums › Add-ons › Repeater Field › Repeater field value in acf/update_value filter › Reply To: Repeater field value in acf/update_value filter
If works!!! 🙂
Thank you very much! Here’s my final code in case it interests someone:
<?php
/**
* Class Henri_ACF_SyncOptions
*
* This class sync the selected options fields between all active languages.
*
*/
class Henri_ACF_SyncOptions {
private static $inited = false;
/**
* @var array
* List fields to update
*/
private static $henri_fields_to_sync = array(
"field_group_henri_settings_general_analytics_henri_google_analytics",
"field_group_henri_settings_general_medias_henri_remove_accent",
"field_group_henri_settings_general_access_disable_update",
"field_group_henri_settings_general_access_password_protect",
"field_group_henri_settings_general_social_henri_social_icons_group",
);
public static function init() {
if ( self::$inited ) {
return;
}
self::$inited = true;
add_action( 'acf/save_post', array( 'Henri_ACF_SyncOptions', 'onPostSave' ), 10 );
}
public static function onPostSave() {
global $sitepress;
if ( ! isset( $sitepress ) ) {
return;
}
// array of field values
$postFields = $_POST['acf'];
$activeLangs = $sitepress->get_ls_languages();
foreach ( self::$henri_fields_to_sync as $fieldToSync ):
if ( isset( $postFields[ $fieldToSync ] ) ):
foreach ( $activeLangs as $key => $value ) {
if ( $key !== ICL_LANGUAGE_CODE ) {
set_global_option_icl( $fieldToSync, $postFields[ $fieldToSync ], $key );
}
}
endif;
endforeach;
}
}
if(is_admin()):
Henri_ACF_SyncOptions::init();
endif;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.