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!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.