I’m also having this issue with the ACF field not being updated in the backend (without full page refresh) using update_field($field_key, $field_value, $post_id) during ‘acf/save_post.’
public function register_hooks()
{
// add_action('acf/save_post', [$this, 'acf_save_post'], 5);
add_action('acf/save_post', [$this, 'acf_save_post'], 20);
}
public function acf_save_post($post_id)
{
$post_type = get_post_type($post_id);
switch ($post_type) {
case 'event':
$this->acf_save_post_event($post_id);
}
}
public function acf_save_post_event($post_id)
{
$field_key = 'field_6247dc975b487';
$new_value = 'hello';
if ($new_value) {
//$_POST['acf'][$field_key] = $new_value;
update_field($field_key, $new_value, $post_id);
} else {
//$_POST['acf'][$field_key] = '';
delete_field($field_key, $post_id);
}
}
I am using the field key rather than the field name. I attempted the methods under “Applied after save” and “Applied before save” at href=”https://www.advancedcustomfields.com/resources/acf-save_post/. This is top-level field, not under a group or repeater. It is a jQuery datepicker field, by I also attempted this with a plain text field, with the same results. The field updates properly in the database, but this isn’t reflected in the post edit screen until a full page refresh. The Gutenberg editor is active for the post type edit, so the page does not fully refresh on “Update.”