Support

Account

Home Forums Backend Issues (wp-admin) how to detect if post is new or edited with pre_save_post()? Reply To: how to detect if post is new or edited with pre_save_post()?

  • Today, I was confronted to a similar issue; now WP (2018) $_POST contains new data and I used something like this: if ( $_POST['original_post_status'] == 'auto-draft' && $_POST['hidden_post_status'] == 'draft' ) to check if it’s a new post or not in 'acf/save_post'. It seems to work ok so far. You probably will want to check the post_type as well if you have a few…

    In the function triggered by 'acf/save_post' you can check the whole $_POST and edit it directly, it contains the ACF values as well (but the array is using some ashed key that you can get with acf_get_field_key you can find here: https://gist.github.com/mcguffin/81509c36a4a28d9c682e

    ACF is really awesome!