WP Residence Help WP Residence Help

  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / 13. WPResidence / WPEstate CRM / WPResidence CRM Installation and Updates — Developer Reference

WPResidence CRM Installation and Updates — Developer Reference

34 views 0

Developer documentation for the activation and migration lifecycle of the WPResidence real estate CRM. Key files: wpestate-crm.php, libs/db-setup.php, libs/migration.php, uninstall.php.

Plugin Constants

WPESTATE_CRM_URL WPESTATE_CRM_DIR_URL WPESTATE_CRM_PATH WPESTATE_CRM_BASE WPESTATE_CRM_VERSION = '5.2.2'

Activation Routine

wpestate_crm_functionality() // lines 331-376 of wpestate-crm.php

Runs on register_activation_hook and is also invoked by wpestate_crm_check_plugin_functionality_loaded() on plugins_loaded when the stored DB version differs from WPESTATE_CRM_VERSION.

Steps

  1. wpestate_crm_create_tables() – create all 9 tables via dbDelta.
  2. wpestate_crm_seed_defaults() – seed default settings, skipping existing non-empty values.
  3. wpestate_crm_migrate_cpt_data() – migrate legacy CPT posts, guarded by wpestate_crm_cpt_migrated flag.
  4. Register manage_crm on the administrator role.
  5. wpestate_crm_seed_permissions() – seed the role-based matrix.
  6. wpestate_crm_migrate_hubspot_settings() – copy legacy Redux keys to CRM settings.
  7. wpestate_crm_seed_default_automations() – insert 27 rules if none exist, all paused.
  8. Schedule 3 cron events if not already scheduled.
  9. update_option(‘wpestate_crm_db_version’, WPESTATE_CRM_VERSION).

Cron Events

Hook Schedule
wpestate_crm_process_automations hourly
wpestate_crm_daily_notifications daily
wpestate_crm_weekly_digest weekly

Deactivation

wpestate_crm_deactivate() // lines 323-328

Clears the three scheduled cron events. Leaves tables and options intact.

Update Detection

wpestate_crm_check_plugin_functionality_loaded() hooks plugins_loaded, compares get_option(‘wpestate_crm_db_version’) against WPESTATE_CRM_VERSION, and re-runs the activation routine on mismatch. This handles the case where the plugin file is replaced via SFTP and no activation hook fires.

Schema Migrations

CPT-to-Table Migration

wpestate_crm_migrate_cpt_data() // libs/migration.php
  • Guard: wpestate_crm_cpt_migrated flag.
  • Inline if total posts <= 500; otherwise batched via WP-Cron at 100 posts per batch.
  • Migrates wpestate_crm_contact posts into wp_wpresidence_crm_contacts, skipping duplicates by email.
  • Migrates wpestate_crm_lead posts into the leads table and creates a form_submission activity per post.
  • Migrates WP comments on the legacy CPT posts into note activities.
  • Leaves original CPT posts in place as reference and does not delete them.

Schema v2 (Column Rename)

wpestate_crm_migrate_schema_v2() // libs/db-setup.php
  • Guard: wpestate_crm_schema_v2_migrated flag.
  • Copies data from legacy column names to new planned column names, such as deal_title → title, deal_stage → stage, and task_title → title.
  • Copies activities with entity_type=’contact’ so they set contact_id instead of entity_id.
  • Does not drop old columns. Both remain for safety.

HubSpot Settings Migration

wpestate_crm_migrate_hubspot_settings() // libs/settings.php
  • Guard: wpestate_crm_hubspot_migrated flag.
  • Copies wp_estate_* Redux keys into the wpestate_crm_settings array under crm_hubspot_* keys.

Viewed Listings Column Rename

In wpestate_crm_create_tables(), if the table has an old user_id column, it renames it to contact_id and drops the old index.

Page Auto-Creation

wpresidence_create_crm_helper_content() // lines 1159-1257

Hooked to wp_loaded. Compares stored setup version, currently 2.1, against the code version and creates any missing CRM pages with the correct _wp_page_template meta.

Uninstall

uninstall.php:

  1. DROP TABLE for all 9 custom tables.
  2. DELETE OPTION for CRM options: wpestate_crm_settings, wpestate_crm_db_version, wpestate_crm_cpt_migrated, wpestate_crm_schema_v2_migrated, wpestate_crm_hubspot_migrated, wpestate_crm_permissions, wpestate_crm_webhooks.
  3. Remove manage_crm capability from all roles.
  4. Delete CRM dashboard pages identified by their _wp_page_template meta value.
  5. Recursively delete the /uploads/wpestate-crm/ directory.
  6. Clear all CRM cron events.

DB Version Option

Key: wpestate_crm_db_version. Value: plugin version string, for example 5.2.2. Updated at the end of every activation run.

Development Tips

  • To force a re-run of activation during development, delete the wpestate_crm_db_version option and reload any admin page.
  • To rewind a migration flag, for example to re-run CPT migration for testing, delete the corresponding *_migrated option.
  • Never edit table schemas directly. Edit libs/db-setup.php and let dbDelta reconcile on the next activation run.
13. WPResidence / WPEstate CRM

Related Articles

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

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
  • 24. FAQ
  • 10. Pages
  • 11. Header
  • 12. Footer
  • 05. Maps & Location Settings
  • 18. Payments & Monetization
  • Plugins
    • 22. Third Party Plugins – IDX Compatibility
    • 21. Third-Party Plugins – Multi-Language
    • 23. Third party Plugins – Other
  • Technical
    • 26. 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