Skip to content

Customized confirmation message

On this page we see how to Customize the message that includes the booking confirmation token (the booking confirmation message sent when online payments are disabled).

Starting from version 1.0.2, the Simple Bike Rental plugin sends the confirmation email in HTML format, making the message more readable and professional.

Two WordPress filters have also been introduced to allow developers to customize the subject and content of the message.

In this guide, we will show you how to do it in a few simple steps.


Edit the email subject

You can edit the email subject using the simpbire_email_subject filter in the functions.php file of your theme (or in a custom plugin):

add_filter('simpbire_email_subject', 'custom_sbr_email_subject', 10, 2);
function custom_sbr_email_subject($subject, $name) {
  return "Confirm your bike rental, $name!";
}

Changing the email content

The simpbire_email_message filter allows you to customize the entire HTML message, including the confirmation link:

add_filter('simpbire_email_message', 'custom_sbr_email_message', 10, 3);
function custom_sbr_email_message($message, $name, $link) {

  $name = esc_html($name);
  $link = esc_url($link);

  return "
  <p>Hi $name,</p>

  <p>Thanks for booking your bike with us!</p>

  <p>Please confirm your rental by clicking the button below:</p>

  <p>
  <a href=\"$link\"
  style=\"display:inline-block;
  padding:12px 24px;
  background-color:#2271b1;
  color:#ffffff;
  text-decoration:none;
  border-radius:4px;
  font-weight:600;\">
  Confirm your reservation
  </a>
  </p>

  <p>If the button does not work, copy and paste this link into your browser:</p>
  <p><a href=\"$link\">$link</a></p>

  <p>Looking forward to seeing you!</p>
  ";
}

You can freely use HTML and insert images, logos, or a custom style.


Security and compatibility

The plugin sanitizes $name with sanitize_text_field() and $link with esc_url_raw() before passing them to the filters. Sanitization does not replace context-specific output escaping: when building your own HTML message, use esc_html($name) for the name and esc_url($link) for the confirmation link, as shown above. The email subject is plain text and does not require HTML escaping.

The plugin passes the filtered subject and message to wp_mail() without additional sanitization or escaping. Apply the appropriate escaping to any dynamic data included in your HTML message, including custom fields, user metadata, and user input.

  • esc_html() for text inside HTML
  • esc_url() for URLs, including link and image URLs
  • esc_attr() for other HTML attribute values

Need help?

If you have any questions about how to apply these filters, you can contact us through the Contact page or open a discussion in the support forum on WordPress.org.