Created
June 4, 2019 07:26
-
-
Save yanknudtskov/cfa35d90ebab48f98db67815c662a8e4 to your computer and use it in GitHub Desktop.
Check if an Advanced Custom Field (ACF field) value changed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Remember to insert the {$field_name} | |
add_filter('acf/update_value/name={$field_name}', 'yanco_check_change_of_field_value', 10, 3); | |
function yanco_check_change_of_field_value( $value, $post_id, $field) { | |
$old_value = get_post_meta($post_id, $field['name'], true); | |
if ($old_value != $value) { | |
// it changed | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment