I have this code:
public function init() {
add_filter('acf/update_value/name=bookitall_fromdate',
array($this, 'check_bookingdates' ), 10, 3);
add_filter('acf/update_value/name=bookitall_todate',
array($this, 'check_bookingdates' ), 10, 3);
}
public function check_bookingdates($new_value, $post_id, $field) {
$post_type = get_post_type( $post_id );
if ( $post_type != 'bookitall_bookings' )
{
return;
}
$old_value = get_post_meta($post_id, $field['name'], true);
if ( $old_value == $new_value ) { //No change
return $new_value;
}
...code to check (comparision) fromdate and to date
}
I want to compare dates and add dates or remove dates from another tables based on from- and to-date.
The issue is that from- date and to-date can be totally different depending in which order the hooks acf/update_value/name=bookitall_fromdate
and acf/update_value/name=bookitall_todate
occurs. I want to do the comparision when both datefields (bookitall_fromdate
and bookitall_todate
) has been updated.
How do I achieve that?
This doesn't have to be with acf-fields. The same question applies when using relevant update_meta_key in a filter.