Home › Forums › ACF PRO › acf_form – "On Update" action › Reply To: acf_form – "On Update" action
Ok, slight change to the above function. Think you have to use the order id rather than the post ID:
function delegate_form_update($value, $order, $field) {
// only do it to certain custom fields
if($field['name'] == 'ticket_alloc') {
// get the old (saved) value
$old_value = get_field('ticket_alloc', $order->get_id());
// get the new (posted) value
$new_value = $_POST['acf']['field_63ca95e88557a'];
// check if the old value is the same as the new value
if($old_value != $new_value) {
// Do something if they are different
} else {
// Do something if they are the same
}
}
// don't forget to return to be saved in the database
return $value;
}
add_filter('acf/update_value', 'delegate_form_update', 10, 3);
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!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.
— Advanced Custom Fields (@wp_acf) February 23, 2023
👉 https://t.co/3UtvQbDwNmhttps://t.co/wfFEVcXVKc
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.