Home › Forums › General Issues › acf/save_post not working with calculated update_field › Reply To: acf/save_post not working with calculated update_field
I’ve just looked back over your code and it is a problem in the first function.
get_fields($post_id);
will only return fields that have already been created in the database. So if there are fields that are not set when the post is initially created, they will not exist and will not have values. This means that $replace = get_field($field_name, $post_id);
will never run on a field that does not already exist in the DB so if(empty($default_value)){
is never true.
I’ll look into how you can work around this….
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.