Howdy,
I have a filter that looks like this:
add_filter('acf/update_value/name=google_maps', function ($value, $post_id, $field, $original) {
update_field('another_field', 'foo', $post_id);
return $value;
});
update_field
does not work, though. For it to work, I had to call it from outside the filter:
add_filter('acf/update_value/name=google_maps', function ($value, $post_id, $field, $original) {
global $updateAnotherFieldId;
global $updateAnotherFieldValue;
$updateAnotherFieldId = $post_id;
$updateAnotherFieldValue = 'foo';
add_action('shutdown', 'update_another_field');
return $value;
});
function update_another_field() {
global $updateAnotherFieldId;
global $updateAnotherFieldValue;
update_field('another_field', $updateAnotherFieldValue, $updateAnotherFieldId);
}
Is there a reason for why update_field
would not work inside an acf/update_value
filter?
This is a single-site installation.