WP Residence Help WP Residence Help

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

WPResidence CRM Notes — Developer Reference

49 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.
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

Help Categories

  • 18Agent, Agency & Developers
  • 5Blog Posts & Blog Lists
  • 38Elementor Shortcodes Built-In
  • 45FAQ
  • 15Footer
  • 5Getting Started
  • 37Header
  • 2IDX & MLSImport
  • 6Installation & Setup
  • 23Installation FAQ
  • 23Maps & Location Settings
  • 21Multi-Language Third Party Plugins
  • 6Other Third party Plugins
  • 19Pages
  • 4Payments & Monetization
  • 20Property Lists, Categories & Archive
  • 36Property Pages & Layouts
  • 31Search & Filtering
  • 162Technical how to | Custom Code Required
  • 8Technical: Actions and filters
  • 6Technical: Child Theme
  • 86Theme Options & Global Settings
  • 6Translations & Languages
  • 16WPBakery Shortcodes
  • 51WPResidence / WPEstate CRM
  • 50WPResidence 5.0 Documentation
  • 8WPResidence Elementor Studio
  • 50WPResidence Translate Plugin

Join Us On

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