Home › Forums › Backend Issues (wp-admin) › The updated field is not refreshed › Reply To: The updated field is not refreshed
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.”
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.