Is this happening on the update_field() call or the delete_field() call.
Either way… when you call these function using the field name ACF attempts to figure out what the field key is. If no value is currently stored for the field for the specific post ID then ACF fails to find the correct field key reference.
When calling any ACF function like update_field() where is it possible that a value does not already exist in the database then you must use the field key when calling this function and not the field name.
Granted, this is probably something in ACF that is causing the error, probably not checking that $field is an array before doing something else. However, even if this was correctly checked and the error was removed the update_field() call would still fail where there is not already a value for the field in the database.
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!
© 2023 Advanced Custom Fields.