Writing a function to send an email to the user on save_post if a taxonomy equals a specific value. However, I only want this to happen when the value is being changed, and not on every save. Is there a way to compare if a value is being updated with a new value versus the same value it already has?
function status_save_email( $post_id ) {
if ( !wp_is_post_revision($post_id) ) {
$slug = 'sessions';
if ( $slug != $_POST['post_type'] ) { return; }
$status = get_the_terms( $post_id, 'status_tax' );
if ( $status != null ){
foreach( $status as $state ) {
$state_name = $state->name ;
}}
if ( $state_name == 'Rejected' || $state_name == 'Approved' ){
echo "bingo";
}
}
}