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

  • Hooking the acf/save_post wont work, since every time the post is updated after it is published the acf/save_post will trigger and replace the original $value with a new $value.

    Consider $value being a unique timestamp that is run only once when the post transitions to the published state. $value = time();

    If this is my functions.php, when the already Published post is updated field_534dc7420db07 gets a new value.

    add_action('acf/save_post', 'my_acf_save_post', 20);
    function my_acf_save_post( $post_id ){
        $stat = get_post_status( $post_id );
        $value = time();
        update_field('field_534dc7420db07', $value, $post_id);

    I can check the status of the post in my_acf_save_post, but only the current value, not if it is transitioning from pending to publish.

    This is the reason I need to, and should, run the transition_post_status.