Good afternoon, when changing the status of a reservation, an email is not sent to the user “for approval” or “Closed”. How can this be fixed?
Aleksei Poryvkin
Hi Aleksei,
By default, notifications are only sent to the bookee when the booking is confirmed. You can hook into any status change, however. Just as an example:
add_action('eventorganiser_transition_booking_status', function($new_status, $old_status, $booking) {
$message = "Booking changed from $old_status to $new_status";
//This the email template chosen in the plugin settings
$template = eventorganiser_pro_get_option( 'email_template' );
$from_name = get_bloginfo( 'name' );
$from_email = eo_get_admin_email( $booking->ID );
$headers = array(
'from:' . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>",
'reply-to:' . $from_email
);
$bookee_email = eo_get_booking_meta( $booking->ID, 'bookee_email' );
eventorganiser_mail( $bookee_email, "subject", $message, $headers, [], $template );
}, 10, 3);
Stephen Harris
Good afternoon, thanks, it works. But was it possible to make different messages (e-mail) for different statuses? When changing to status, one letter is approved, and another is closed. And another question, how to translate into Russian the statuses themselves that come in the letter?
http://joxi.ru/1A5dbX9iDPZDY2
Aleksei Poryvkin
Hi Aleksei,
You can use the $old_status
and $new_status
variables to target a particular transition.
E.g.
add_action('eventorganiser_transition_booking_status', function($new_status, $old_status, $booking) {
if ($new_status === 'pending' && $old_status === 'confirmed') {
//Booking was confirmed, but is now pending
$message = '...'; //set email message as appropriate
$subject = '...'; //set email subject as appropriate
} else if ( $new_status === 'confirmed' ) {
//Booking was previously not confirmed, but is now confirmed
$message = '...'; //set email message as appropriate
$subject = '...'; //set email subject as appropriate
} else {
//Otherwise don't send an email
return;
}
//...
}, 10, 3);
The above allows you to set a different message for bookings which go from confirmed to pending (for whatever reason) or bookings which transition to confirmed (from any status).
In that way, you can target bookings which go from and to particular statuses, or which go from a particular status, or go to a particular status.
As you are setting the $message
and $subject
yourself, you can just write the content in Russian.
Stephen Harris