WP Residence Help WP Residence Help

  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / 13. WPResidence / WPEstate CRM / WPResidence CRM Auto-Create From Forms — Developer Reference

WPResidence CRM Auto-Create From Forms — Developer Reference

12 views 0

Developer documentation for the form-to-CRM pipeline in the WPResidence real estate CRM. Entry point is libs/auto-create.php.

Entry Point

wpestate_crm_process_form_submission( $form_data )

Called by the theme’s form handlers with a structured array that identifies the form, the prospect, and the target property or agent if any.

Expected Form Data

  • contact_name – split into first_name, last_name on the first space.
  • contact_email – required; validated with is_email().
  • contact_mobile – phone number.
  • details – message body.
  • propid – property post ID (optional).
  • agent_id – agent post ID (optional).
  • form_type – origin identifier.

Form Type Map

form_type Enquiry type
property Property Inquiry
schedule_section Schedule Tour
contact_page General Question
agent Property Inquiry
footer General Question

Pipeline Steps

  1. Validate email; abort if invalid.
  2. Call wpestate_crm_find_contact_by_email($email).
  3. If matched: update existing contact (merge mode) via wpestate_crm_update_contact().
  4. If not matched: call wpestate_crm_insert_contact() with lifecycle_stage=’new_lead’, lead_source=’website’.
  5. Populate buyer preferences from property metadata if propid is present, only on empty preference fields.
  6. Set tracking cookie wpestate_crm_contact_id (1-year, HttpOnly, SameSite=Lax, Secure on HTTPS) if headers were not sent.
  7. Insert enquiry row via wpestate_crm_insert_enquiry().
  8. Record form_submission activity via wpestate_crm_record_activity_v2() with meta: {form_type, listing_id}.
  9. Hooks fire downstream: email notifications, Twilio, HubSpot, webhooks, automations.

Lead Owner Detection

wpestate_crm_detect_lead_owner( $form_data )

Priority:

  1. If agent_id is present, resolve the CPT meta user_meda_id (intentional typo preserved) to a WP user ID.
  2. Else if propid is present, use the property’s post_author.
  3. Else fallback to the site admin, user ID 1 via wpestate_crm_return_admin_id().

Buyer Preferences Auto-Fill Details

When propid is set, the function reads property attributes and fills the contact’s preference fields if empty:

  • property_category tax term → pref_property_type.
  • property_city tax term → pref_locations.
  • property_bedrooms → pref_min_beds, pref_max_beds.
  • property_bathrooms → pref_min_baths, pref_max_baths.
  • property_price → 80% to pref_min_price, 120% to pref_max_price.
  • property_size → 80% to pref_min_area, 120% to pref_max_area.

No Direct Hooks

This module does not register its own add_action() calls. It is invoked directly by the theme’s contact form handlers. All downstream side effects use the CRM’s own hooks, such as wpestate_crm_after_insert_contact and wpestate_crm_after_record_activity, via other modules.

Tracking Cookie

See the Viewed Tracking developer article for the full cookie lifecycle. Tracking begins the moment process_form_submission completes. The first property page the prospect views after the form submission is attributed to them.

Testing

  • Enable the CRM and submit a property contact form as an anonymous visitor.
  • Verify: new row in wp_wpresidence_crm_contacts; new row in wp_wpresidence_crm_enquiries; form_submission row in wp_wpresidence_crm_activities; cookie in browser; contact visible in CRM dashboard.
  • Re-submit with the same email and verify the existing contact is updated, with no duplicate.

Related

HubSpot sync of auto-created contacts runs via the wpestate_crm_after_insert_contact hook. See the HubSpot CRM integration guide.

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