Support

Account

Home Forums Backend Issues (wp-admin) update_field is not working in action hook Reply To: update_field is not working in action hook

  • 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.