WP Residence Help WP Residence Help

  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / 29. WPResidence CRM / WPResidence CRM Property Matching — Developer Reference

WPResidence CRM Property Matching — Developer Reference

1 view 0

Developer documentation for the matching engine in the WPResidence real estate CRM. The engine lives in libs/matching-functions.php and matches buyer preference fields stored on contacts against estate_property posts.

Core Function

wpestate_crm_match_properties( $contact_id, $args = [] )

$args supports per_page, paged, agent_only. Returns {post_ids: int[], count: int}.

Input Fields Used

Read from the contacts table: pref_property_type, pref_property_status, pref_locations, pref_min_price, pref_max_price, pref_min_beds, pref_max_beds, pref_min_baths, pref_max_baths, pref_min_area, pref_max_area.

Query Construction

A WP_Query is built against post_type=estate_property with:

  • tax_query: relation AND. property_category + property_status filters. Location is a nested OR matching city or area taxonomy terms.
  • meta_query: relation AND. BETWEEN filters on property_price, property_bedrooms, property_bathrooms, property_size.
  • post_status=publish.

Missing preference fields are skipped (no filter added). A contact with no preferences returns an empty result rather than all listings.

AJAX Endpoints

Action Nonce Purpose
wpestate_crm_match_properties wpestate_crm_nonce (security param) Run match; returns post data
wpestate_crm_email_matches wpestate_crm_nonce Email matched listings to contact
wpestate_crm_get_viewed_listings wpestate_crm_nonce Fetch viewed-listings history (related feature)

Email Dispatcher

wpestate_crm_ajax_email_matches() builds an HTML email with one property card per listing (thumbnail, title, price, beds, baths, area) and sends it via wpestate_send_emails() (or wp_mail() fallback).

Settings

  • wp_estate_crm_matching_email_subject — default Properties matching your preferences.
  • wp_estate_crm_matching_email_header — HTML above the listing cards.
  • wp_estate_crm_matching_email_footer — HTML below the listing cards.
  • wp_estate_crm_matching_email_max_listings — per-email cap, default 20.

Placeholders

Supports the 20-placeholder set from wpestate_crm_resolve_placeholders(). Common ones: {contact_name}, {site_name}, {agent_name}.

Activity Record

Each email records a listing_email_sent activity with meta JSON containing listing_count and listing_ids.

New-Listing Trigger

Hooked to publish_estate_property. When a listing is published for the first time, a one-time cron wpestate_crm_match_new_listing is scheduled 60 seconds later. The handler runs match queries against all active contacts with buyer preferences and emails them the new listing if it is a fit.

Automation Action

The action type run_matching (in libs/automations.php) calls wpestate_crm_match_properties() and optionally emails the agent if matches are found. Used by default rules 24, 25, 26.

Scoring

Matching is currently binary — a listing is either within the preference ranges or it is not. There is no numerical score. Extend by adding a custom filter that ranks the returned post IDs by some proximity metric (e.g., distance from midpoint price).

Extending

  • Add custom meta filters by extending the query builder in a child plugin and hooking a filter on the returned WP_Query arguments.
  • Store additional preference fields on the contact row as custom meta or in a dedicated extension table; the engine reads from the contacts table by column name.
  • For very large inventories, consider switching the engine to use a dedicated search index table (the theme has an in-progress wpestate_26_search_index module for this purpose).
29. WPResidence 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
  • 13. 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