Support

Account

Home Forums General Issues update_field on Publish Reply To: update_field on Publish

  • Hi,
    I had a similare issue where when i substracted 1 to the post id it was working and with the current post ID it wasen’t.
    In my case it was caused by the fact that at the point of updating the field value, the values wasen’t saved yet.

    I am not sure if i understand what you are trying to achive but it looks like you want to register a value to the posts that wasen’t published ang got changed to publish.

    If you are trying to do that for new post and want the function to run only when post is created you could use

    // run before ACF saves the $_POST['fields'] data
    add_action('acf/save_post', 'my_acf_save_post', 1);

    inside your my_acf_save_post you could check if field_534dc7420db07 is set.
    If it is it will mean you are juste updating the post if it dosen’t it means it’s a new post and you can update the field value.

    If you are trying to run your function when a post pass from private to published
    have you tried to call private_to_published action?

    hope it helps