WP Residence Help WP Residence Help

  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / WPResidence / WPEstate CRM / WPResidence CRM Email Notifications — Developer Reference

WPResidence CRM Email Notifications — Developer Reference

54 views 0

Developer documentation for the email notifications module of the WPResidence real estate CRM. Entry point is libs/notifications.php.

Send API

wpestate_crm_send_notification_email( $event, $data )

Flow:

  1. Read subject and body from settings (wp_estate_subject_crm_notify_{event} and wp_estate_crm_notify_{event}).
  2. If either is empty, abort — the event is effectively disabled.
  3. Resolve placeholders via wpestate_crm_resolve_placeholders().
  4. Determine recipient: $data[‘recipient_email’] → $data[‘agent_email’] → site admin.
  5. Apply nl2br() to body for HTML.
  6. Wrap with wpestate_crm_wrap_email_template().
  7. Send via wpestate_send_emails() with wp_mail() fallback.
  8. Record email_sent activity on the contact.

Supported Events

  • new_contact
  • contact_assigned
  • deal_stage
  • deal_won
  • task_overdue
  • task_due_today

Placeholder Resolver

wpestate_crm_resolve_placeholders( $template, $data )

Replaces 20 placeholders — see the user-facing article for the full list. Internals:

  • {contact_phone} resolves to $data[‘mobile’], falling back to phone, then home_phone.
  • {listing_price} uses the theme’s currency label via wpresidence_get_option(‘wp_estate_currency_label_main’).
  • {task_due_date} uses date_i18n(get_option(‘date_format’)).
  • {crm_contact_url} / {crm_deal_url} generate links to the dashboard pages with ?contact_detail=ID / ?deal_detail=ID.

Template Wrapper

wpestate_crm_wrap_email_template( $subject, $body )

Loads templates/email_templates/base_email_template.php via locate_template(), captures its output with ob_start(), and returns the wrapped HTML. Respects the theme option wpestate_email_type: when set to text, the wrapper is skipped and a plain-text message is returned.

Hook Registrations

Hook Priority Callback
wpestate_crm_after_insert_contact 20 wpestate_crm_on_new_contact_notification()
wpestate_crm_after_update_contact 20 wpestate_crm_on_contact_assigned_notification() (detects assigned_agent_id change)
wpestate_crm_after_update_deal 10 wpestate_crm_on_deal_update_notification() (handles stage change and won detection)
wpestate_crm_daily_notifications — wpestate_crm_daily_task_notifications()

Daily Task Cron

wpestate_crm_daily_notifications is scheduled on plugin activation. The handler:

  1. Queries the tasks table for due_date < today AND status not Completed/Cancelled. Groups by user_id.
  2. Queries tasks where due_date >= today AND due_date < tomorrow AND status not Completed/Cancelled. Groups by user_id.
  3. Sends one task_overdue email per agent using the first task’s data as template context.
  4. Sends one task_due_today email per agent.

Settings Keys

Per event, two keys:

  • wp_estate_subject_crm_notify_{event}
  • wp_estate_crm_notify_{event}

Both are stored in the theme’s Redux option store (not in the CRM’s own settings array). This was a deliberate consolidation so admins manage all email templates in one place — Theme Options → Email Management → CRM Emails.

Extending

  • Register a new event by hooking a CRM event and calling wpestate_crm_send_notification_email($new_event, $data).
  • Add new placeholders by filtering the resolver output in a child plugin.
  • Override the wrapper by placing a base_email_template.php in your child theme’s templates/email_templates/ directory — locate_template() will pick it up first.
WPResidence / WPEstate CRM

Related Articles

  • WPResidence CRM Security Model — Developer Reference
  • CRM Security and Data Privacy
  • WPResidence CRM Installation and Updates — Developer Reference
  • Installing and Updating the WPResidence CRM

Help Categories

  • 18Agent, Agency & Developers
  • 5Blog Posts & Blog Lists
  • 38Elementor Shortcodes Built-In
  • 45FAQ
  • 15Footer
  • 5Getting Started
  • 37Header
  • 2IDX & MLSImport
  • 6Installation & Setup
  • 23Installation FAQ
  • 23Maps & Location Settings
  • 21Multi-Language Third Party Plugins
  • 6Other Third party Plugins
  • 19Pages
  • 4Payments & Monetization
  • 20Property Lists, Categories & Archive
  • 36Property Pages & Layouts
  • 31Search & Filtering
  • 162Technical how to | Custom Code Required
  • 8Technical: Actions and filters
  • 6Technical: Child Theme
  • 86Theme Options & Global Settings
  • 6Translations & Languages
  • 16WPBakery Shortcodes
  • 51WPResidence / WPEstate CRM
  • 50WPResidence 5.0 Documentation
  • 8WPResidence Elementor Studio
  • 50WPResidence Translate Plugin

Join Us On

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