WP Residence Help WP Residence Help

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

WPResidence CRM Email Notifications — Developer Reference

14 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.
13. 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

WP Residence Documentation

  • 01. Getting Started
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 02. Installation & Setup
  • 03. Installation FAQ
  • 06. Search & Filtering
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 09. Agent, Agency & Developers
  • 08. Property Pages & Layouts
  • 07. Property Lists, Categories & Archive
  • 14. WPResidence Elementor Studio
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • 04. Theme Options & Global Settings
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • 20. Translations & Languages
  • 26. FAQ
  • 10. Pages
  • 11. Header
  • 12. Footer
  • 05. Maps & Location Settings
  • 18. Payments & Monetization
  • Plugins
    • 19. Included Plugins
    • 22. Third Party Plugins – IDX Compatibility
    • 21. Third-Party Plugins – Multi-Language
    • 23. Third party Plugins – Other
  • Technical
    • 24. Technical how to | Custom Code Required
    • 25. Technical: Child Theme

Join Us On

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