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 situation:
    i have a custom post type where fields are created using php (not acf gui). one of the fields, a readonly text area, is supposed to be populated after users save draft then click publish.

    the actual code:
    created a function that do some string generation using while loop. at the last line of the function, update_field the text area. it hooked into draft_to_publish action with priority 10 (tried 5 and 20, same issue)

    the problem:
    all codes in the function are run without error (this is tested and verified) but the field is not updated.

    the test:
    we copied all codes inside the function to a page template, link it with that particular content, visit the permalink to execute the code. it runs fine and updated the textarea field

    hope that’s more clear on the problem