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_postaction. 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_postaction, but again does not produce the final meta key/value associations required
wp_insert_post()and manually updating the post,
get_field_object()returns empty field definitions since the
$field_keyvariable contains the name of a field that does not have a corresponding meta value
acf/save_postmanually does not work as the function requires a populated
$_POSTvariable. Manually saving the post works, since the
$_POSTobject contains field GUIDs, then calls
$fieldis an empty field definition
It 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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 29, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.