I want to check if select field changed it’s value after post editing, and if it is, then to send an email to admin.
I saved previous value to a variable $pre_status_eksperimenta using acf/pre_save_post, like this:
function action_pre_post_update( $post_id ) {
$pre_status_eksperimenta = get_post_meta($post_id, 'status', true);
};
add_action( 'acf/pre_save_post', 'action_pre_post_update', 10, 1 );
When I var_dump($pre_status_eksperimenta) I get correct value, wich means it works.
Then I want to pass that to a acf/save_post hook and check if there was a change, but now when I var_dump($pre_status_eksperimenta) I get NULL
function status_change_notification($ID) {
var_dump($pre_status_eksperimenta);
die();
}
add_action( 'acf/save_post', 'status_change_notification', 10, 1);
I think its about variable scope. You should global it when you use it in another function.
and then