The code below sends out an email every time I (change the STATUS field and then) safe/update the post. But it\'s not working the way I want and I know whats\'s wrong:
T
UPDATE 2 Got it working. Code below:
add_action('acf/save_post', 'yl_send_booking_email_after_status_update', 5);
function yl_send_booking_email_after_status_update( $post_id ) {
// Get submitted values.
$values = $_POST['acf'];
// Check if a specific value was updated.
if( isset($_POST['acf']['field_5ed8117407663']) ) {
$to = $_POST['acf']['field_5ed41758ed4b5'];
$subject = $_POST['acf']['field_5ed81174076f2'];
$message = $_POST['acf']['field_5ed8117407741'];
$headers = array
(
'From: ' . get_bloginfo('name') . ' <' . get_bloginfo('admin_email') . '>',
'Bcc: ' . get_bloginfo('admin_email'),
'X-Mailer: PHP/' . phpversion(),
'MIME-Version: 1.0',
'Content-type: text/html; charset=iso-8859-1'
);
$headers = implode( "\r\n" , $headers );
wp_mail( $to, $subject, $message, $headers );
}
}