Home › Forums › ACF PRO › Check if field has changed when save to change mail › Reply To: Check if field has changed when save to change mail
Let’s say that your field name is “text_field” and it has a field key of “field_123456”
Notice I’m only using the field key, since you must use the field key for the new values you might just as well use it for both.
add_filter('acf/save_post', 'my_compare_acf_fields', 1);
function my_compare_acf_fields($post_id) {
$old_value = get_field('field_123456', $post_id);
$new_value = '';
if (isset($_POST['acf']['field_123456'])) {
$new_value = $_POST['acf']['field_123456'];
}
if ($new_value != $old_value) {
// value has changed, do something
}
}
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.