Home › Forums › Backend Issues (wp-admin) › update_field on new post creates mismatched meta_keys before save_post() › Reply To: update_field on new post creates mismatched meta_keys before save_post()
We’ve been doing a bit of troubleshooting. The problem seems to lie with a failed field GUID lookup, having provided a top-level field name.
save_post
action. This means that the database contains errant meta keys and values for myfield, _myfield, field_myfield and field_###########wp_insert_post()
does execute the save_post
action, but again does not produce the final meta key/value associations requiredwp_insert_post()
and manually updating the post, get_field_object()
returns empty field definitions since the $field_key
variable contains the name of a field that does not have a corresponding meta valueacf/save_post
manually does not work as the function requires a populated $_POST
variable. Manually saving the post works, since the $_POST
object contains field GUIDs, then calls acf/update_value
acf/update_value
fails because $field
is an empty field definitionIt seems that we need a solid way to update fields that are attached to a programmatically-created post before the post ACF meta data has been initialized.
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.