WP Residence Help WP Residence Help

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

WPResidence CRM Notes — Developer Reference

11 views 0

Developer documentation for the Notes module in the WPResidence real estate CRM. Notes are polymorphic. A single table stores notes for contacts, leads, enquiries, deals, and tasks.

Storage – wp_wpresidence_crm_notes

Created in libs/db-setup.php. Columns:

Column Purpose
note_id Primary key
entity_type One of: contact, lead, enquiry, deal, task
entity_id Foreign key into the matching entity table
user_id Note author (WP user ID)
note_text longtext – the note body
created_at Timestamp

Index on (entity_type, entity_id) for fast per-record lookups.

CRUD API – libs/notes-crud.php

Function Purpose
wpestate_crm_insert_note($data) Insert; required: entity_type, entity_id, user_id, content (mapped to note_text)
wpestate_crm_get_notes($entity_type, $entity_id, $args) Fetch notes for one record; supports limit (default 20), offset, order (default DESC)
wpestate_crm_delete_note($note_id) Delete one
wpestate_crm_bulk_delete_notes($ids) Bulk delete; returns int count
wpestate_crm_sanitize_note_data($data) Sanitizer – maps content to note_text, applies sanitize_textarea_field(), casts IDs with absint()

Mirror to Activities Table

Each note insert also creates a note-type row in wp_wpresidence_crm_activities via wpestate_crm_record_activity_v2(). This is what makes notes appear in the unified timeline alongside system events.

Hooks

  • wpestate_crm_after_add_note – fired after insert. Consumed by the automations engine (triggers note_added event) and downstream analytics.

Permissions

Gated by wpestate_crm_user_can($entity_type_plural, $action). Delete enforces authorship: only the note’s user_id or an administrator can delete. All users with view access to the parent record can read notes.

Usage From Other Modules

The contact detail page (templates/crm_contact_detail.php) includes an Add Note form. The form submits via an AJAX action that wraps wpestate_crm_insert_note(). Render loops use wpestate_crm_get_notes(‘contact’, $contact_id).

Extending

  • Add your own entity types by writing an entity_type string. The table is not constrained to the five defaults. Just make sure your render loop knows how to resolve the entity_id.
  • For rich text or attachments, store markup in note_text and escape with wp_kses_post() on output. The default sanitizer uses sanitize_textarea_field(), which strips tags, so customize in a child plugin if you need HTML notes.
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