I’m a little bit confused if ACF is capable of something that i’ve been trying to accomplish. What i’d like to have is a seamless syncing of cloned values throughout the site by having all the main components under options page and then cloning them into field groups.
Right now whenever i use a clone field, the values do not get synced from the options page. So far i’ve accomplished it with this
add_filter('acf/prepare_field', function($field){
$current_screen = get_current_screen();
if($current_screen && $current_screen->id == 'toplevel_page_theme-settings') return $field;
$components = get_field('components', 'option');
foreach($components as $component){
if(array_key_exists($field['_name'], $component)){
if(isset($field['sub_fields'])){
// foreach($field['sub_fields'] as $field_key => $sub_field){
// foreach($component[$field['_name']] as $sub_component){
// if(array_key_exists($sub_field['_name'], $sub_component)){
// //$field['sub_fields'][$field_key]['value'] = $sub_component[$sub_field['_name']];
// //consoleLog([$field, $sub_field, $sub_component[$sub_field['_name']]]);
// }
// }
// }
}else{
$field['value'] = $component[$field['_name']];
}
}
}
return $field;
},10,3)
But this solution does not work with repeater fields. I am unable to save any repeater fields unless Prefix Field Names is selected but then it is not an exact clone anymore. Also i would like to leave this option untouched so that the user can have a seperate values for specific posts.
Am i missing something? I’ve been trying to implement this feature for quite some time now but so far i’ve been unuccessful.
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.