The problem here, I think, is that you’re attempting to update a field that does not exist when you’re trying to update it. Try using the field key instead of the field name. https://www.advancedcustomfields.com/resources/update_field/ the field key should always be used when saving values that are new.
Also set the priority > 10. ACF uses the same hooks to update fields that we use and it uses the default priority of 10. If for some reason ACF runs after your filter then it will overwrite whatever you update the field to.
The final issue could be using the draft_to_publish hook. I don’t know the details this hook, when it is called or how it works. It could be possible that whatever values you’re trying to get to update the value of your field don’t exist, but you said that “all codes in the function are run without error (this is tested and verified)” so I’m guessing that this isn’t the problem.
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!
© 2022 Advanced Custom Fields.