WPRentals Theme Documentation WPRentals Theme Documentation

  • Client Support
  • Video Tutorials
  • WPRentals
  • WPEstate
  • API
Home / Email Notifications, Technical how to, WP Rentals Theme Options / How SMS Notifications Work in WP Rentals (WpestateEmail Class): A Complete Guide

How SMS Notifications Work in WP Rentals (WpestateEmail Class): A Complete Guide

1862 views

Overview

This technical help explains how WPRentals sends SMS notifications through the notification system.

The SMS flow is connected to the email notification flow. When a supported notification is triggered, WPRentals first prepares the email notification and then checks if an SMS should also be sent for the same notification type.

The main logic is handled in the WPRentals Core plugin file:

plugins/wprentals-core/classes/wpestate_email.php

Important: This article is intended for developers or advanced users who need to understand the internal SMS notification flow. Do not edit WPRentals Core plugin files directly on a live site. Changes made directly in plugin files can be lost after updates.

CONTENT

  • Main SMS notification flow
  • Main file and related functions
  • wpestate_send_email()
  • wpestate_select_sms_type()
  • wpestate_sms_filter_replace()
  • wpstate_call_twilio_sms()
  • Required conditions before SMS is sent
  • Options and user meta used by SMS
  • SMS templates and placeholders
  • Phone validation logic
  • Twilio delivery logic
  • Technical debugging checklist
  • Developer notes
  • Summary table

Main SMS Notification Flow

The SMS notification flow starts from the same notification system used for email notifications.

The general flow is:

  1. A supported website action is triggered, such as a booking confirmation, new message, listing approval, password reset, or phone validation.
  2. The notification system calls wpestate_send_email().
  3. The email notification is prepared and sent.
  4. The function checks if an SMS notification should also be sent for the same notification type.
  5. The SMS logic checks if SMS notifications are enabled.
  6. The SMS logic checks the recipient phone number.
  7. The SMS logic checks if the user is eligible to receive the SMS.
  8. The correct SMS template is loaded based on the notification type.
  9. Template placeholders are replaced with real values.
  10. The final SMS body is sent through Twilio.
Important: Email and SMS are separate delivery systems. The email can be sent successfully while the SMS is skipped or fails because of SMS settings, missing phone data, missing template text, or Twilio configuration.

Main File and Related Functions

The SMS notification logic is located in:

plugins/wprentals-core/classes/wpestate_email.php

The main functions involved in the SMS flow are:

Function Purpose
wpestate_send_email() Main notification entry point. It prepares and sends the email notification and can trigger the SMS check.
wpestate_select_sms_type() Checks SMS settings, user eligibility, phone validation, notification type, and SMS template.
wpestate_sms_filter_replace() Replaces placeholders in the SMS template and prepares the final SMS body.
wpstate_call_twilio_sms() Sends the prepared SMS message through Twilio.

wpestate_send_email()

wpestate_send_email() is the main notification function.

It receives the recipient email address, the notification type, and the notification arguments.

After the email content is prepared and the email notification is sent, this function can call wpestate_select_sms_type() with the user mobile number, notification type, notification arguments, user email, and user ID.

The key point is that SMS is triggered from the email notification flow. The SMS logic receives the same notification type and arguments used for the email.

Important: If a custom event does not call wpestate_send_email(), the SMS flow connected to this class will not run for that event.

wpestate_select_sms_type()

wpestate_select_sms_type() decides if an SMS should be sent.

This function receives the user mobile number, notification type, notification arguments, user email, and user ID.

This function checks:

  • If SMS notifications are enabled.
  • If the user is eligible to receive SMS.
  • If the user phone is validated when validation is required.
  • If an SMS template exists for the current notification type.
  • If the SMS template has content.
  • If Twilio settings are available.

If all conditions pass, the function prepares the SMS message and sends it through the Twilio SMS function.

wpestate_sms_filter_replace()

wpestate_sms_filter_replace() prepares the final SMS text.

It receives the user phone number, the SMS template, the notification arguments, and the user email address.

This function replaces supported placeholders with real values before the SMS is sent.

Common placeholders can include:

  • %username
  • %website_url
  • %website_name
  • %user_email
Important: The available placeholders depend on the notification type and on the values passed in the notification arguments. If a placeholder is not supported or no value is passed for it, it may not be replaced correctly.

wpstate_call_twilio_sms()

wpstate_call_twilio_sms() sends the final SMS message through Twilio.

This function depends on the Twilio settings saved in WPRentals options.

The required Twilio option values are:

Option Purpose
wp_estate_twilio_api_key Twilio Account SID.
wp_estate_twilio_auth_token Twilio Auth Token.
wp_estate_twilio_phone_no Twilio sender phone number.
Important: If the Twilio credentials are missing, incorrect, or the Twilio number cannot send SMS, the SMS delivery will fail. Check the Twilio logs for the exact delivery error.

Required Conditions Before SMS Is Sent

An SMS notification is sent only when all required conditions are met.

Condition Required Value or Behavior
SMS enabled wp_estate_sms_verification must be set to yes.
User mobile number The recipient user must have a mobile number saved.
Phone validation For most notification types, check_phone_valid must be set to yes.
Admin exception SMS may be allowed when the current user is an administrator, depending on the notification flow.
Validation SMS exception The phone validation SMS can be sent before the phone is marked as validated.
SMS template A template must exist for the current notification type.
Twilio credentials Twilio Account SID, Auth Token, and sender phone number must be configured.
Recipient number format The phone number should be saved in full international format, for example +12345678901.

Options and User Meta Used by SMS

WPRentals Options

The SMS system uses values saved in the WPRentals options system. These values are loaded with wprentals_get_option().

Option Description
wp_estate_sms_verification Enables or disables SMS notifications.
wp_estate_twilio_api_key Stores the Twilio Account SID.
wp_estate_twilio_auth_token Stores the Twilio Auth Token.
wp_estate_twilio_phone_no Stores the Twilio sender phone number.
wp_estate_sms_[type] Stores the SMS template for a specific notification type.

User Meta

User Meta Description
mobile Stores the user mobile phone number.
check_phone_valid Stores whether the user phone number is validated. The expected validated value is yes.

SMS Templates and Placeholders

Each supported SMS notification type has its own template option.

The template option name follows this general pattern:

wp_estate_sms_[type]

Examples:

  • wp_estate_sms_booking_confirmed
  • wp_estate_sms_new_message

The notification type passed to wpestate_send_email() is used to determine which SMS template should be loaded.

SMS templates can include placeholders. Placeholders are replaced in wpestate_sms_filter_replace() before the SMS is sent.

Common placeholders include:

  • %username
  • %website_url
  • %website_name
  • %user_email
Important: Keep SMS templates short. Long SMS messages may be split into multiple SMS parts by Twilio, which can increase SMS cost.

Phone Validation Logic

For most SMS notifications, the recipient phone number must already be validated.

The validation status is stored in user meta:

check_phone_valid = yes

If the user phone number is not validated, SMS is not sent in most cases.

Exceptions can include:

  • The SMS type is the phone validation SMS.
  • The current user triggering the flow is an administrator.

This validation check prevents regular notifications from being sent to unverified phone numbers.

Twilio Delivery Logic

After the SMS template is prepared, WPRentals sends the message through Twilio.

Twilio delivery depends on:

  • The Twilio Account SID.
  • The Twilio Auth Token.
  • The Twilio sender phone number.
  • The destination phone number.
  • The destination country and Twilio account permissions.
  • The SMS capability of the Twilio sender number.

The recipient phone number should be saved in international format, for example:

+12345678901

Important: If Twilio rejects the message, the exact reason must be checked in the Twilio logs. The theme can call Twilio, but Twilio controls the final SMS delivery response.

Technical Debugging Checklist

Email Is Sent but SMS Is Not Sent

  • Confirm the notification action calls wpestate_send_email().
  • Confirm wpestate_select_sms_type() is called after the email logic.
  • Check the notification type value.
  • Check if a matching wp_estate_sms_[type] template exists.
  • Check if the SMS template field is not empty.
  • Check if the recipient user has a saved mobile number.
  • Check if check_phone_valid is set to yes when required.
  • Check if SMS notifications are enabled with wp_estate_sms_verification.

SMS Template Is Loaded but Text Is Wrong

  • Check the template text saved in WPRentals options.
  • Check placeholder spelling.
  • Check which placeholders are supported by that notification type.
  • Check if the values needed by the placeholders are passed in the notification arguments.
  • Check wpestate_sms_filter_replace() for the placeholder replacement logic.

Twilio Call Fails

  • Check wp_estate_twilio_api_key.
  • Check wp_estate_twilio_auth_token.
  • Check wp_estate_twilio_phone_no.
  • Check if the Twilio sender number supports SMS.
  • Check if the recipient phone number uses international format.
  • Check if the destination country is enabled or allowed in Twilio.
  • Check Twilio logs for the exact error message.

User Phone Is Not Accepted

  • Check the value stored in the user mobile meta.
  • Use full international phone format.
  • Do not use local-only numbers.
  • Check if the user phone validation meta is set correctly.
  • Check if the current notification type requires phone validation.

SMS Sends for Admin but Not for Normal Users

  • Check the admin exception in the SMS eligibility logic.
  • Check if the normal user has check_phone_valid set to yes.
  • Check if the normal user has a valid mobile number saved.
  • Check if the SMS type is allowed for non-admin users.

Developer Notes

The SMS sending logic is tied to the notification type passed to wpestate_send_email().

To add or debug an SMS notification type, a developer should check:

  • Where the notification event calls wpestate_send_email().
  • What notification type is passed.
  • What values are passed in the notification arguments.
  • Whether a matching wp_estate_sms_[type] option exists.
  • Whether that option contains an SMS template.
  • Whether placeholder replacement supports the required values.
  • Whether the user has mobile and validation meta.
  • Whether Twilio options are available.

Core values are loaded with:

wprentals_get_option()

Relevant internal values:

  • wp_estate_sms_verification
  • wp_estate_twilio_api_key
  • wp_estate_twilio_auth_token
  • wp_estate_twilio_phone_no
  • wp_estate_sms_[type]
  • mobile
  • check_phone_valid
Important: Avoid editing plugins/wprentals-core/classes/wpestate_email.php directly. Use a custom plugin, child theme logic, or developer-approved hooks/overrides when customization is required.

Summary Table

Setting / Function / Meta Type Purpose
plugins/wprentals-core/classes/wpestate_email.php File Main file where the email and SMS notification logic is handled.
wpestate_send_email() Function Main email notification function. Can trigger SMS flow after email logic.
wpestate_select_sms_type() Function Checks whether SMS should be sent for the notification type and user.
wpestate_sms_filter_replace() Function Replaces SMS placeholders and prepares the final message body.
wpstate_call_twilio_sms() Function Sends the SMS message through Twilio.
wp_estate_sms_verification Option Enables or disables SMS notifications.
wp_estate_twilio_api_key Option Stores the Twilio Account SID.
wp_estate_twilio_auth_token Option Stores the Twilio Auth Token.
wp_estate_twilio_phone_no Option Stores the Twilio sender phone number.
wp_estate_sms_[type] Option Stores the SMS template for a notification type.
mobile User meta Stores the recipient mobile phone number.
check_phone_valid User meta Stores whether the user phone number is validated.

Important Notes

  • The SMS flow is connected to the WPRentals email notification flow.
  • The main logic is in plugins/wprentals-core/classes/wpestate_email.php.
  • The SMS notification depends on the notification type.
  • The matching SMS template is stored as wp_estate_sms_[type].
  • Most SMS notifications require the user phone to be validated with check_phone_valid = yes.
  • SMS templates are plain text and use placeholders replaced before sending.
  • Twilio credentials must be configured before SMS can be delivered.
  • Twilio delivery issues must be checked in the Twilio logs.
  • Do not modify WPRentals Core plugin files directly unless you maintain a controlled custom version.
Email NotificationsTechnical how toWP Rentals Theme Options

Related Articles

  • How to Make a Contact Button Open WhatsApp
  • What Is the WPESTATE FAN Option
  • Why are emails from my website going to the junk or spam folder?
  • How to add a new currency in Theme Options for payments.

HELP CATEGORIES

  • 61. General
  • 72. Installation & Basic Setup
  • 373. How Booking Works
  • 18Advanced Search
  • 17Elementor WPRentals Studio
  • 14Email Notifications
  • 27FAQ
  • 14Installation FAQ
  • 10Menu Options
  • 33Owner & Renter
  • 8Page Templates
  • 24Property / Listing
  • 22Shortcodes
  • 4Supported Maps
  • 99Technical how to
  • 5Third Party plugins
  • 4Translation & Multi Languages
  • 3WordPress Blog Post
  • 13WordPress Widgets
  • 12WP Rentals Payments
  • 80WP Rentals Theme Options
  • 26WPML & Weglot

Join Us On

Powered by WP Estate - All Rights Reserved
  • Client Support
  • Video Tutorials
  • WPRentals
  • WPEstate
  • API