WP Residence Help WP Residence Help

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

WPResidence CRM Bulk Actions — Developer Reference

8 views 0

Developer documentation for the bulk action subsystem in the WPResidence real estate CRM. Covers the AJAX endpoints, operations matrix, and helper functions in libs/bulk-functions.php.

AJAX Endpoints

Action Entity
wpestate_crm_bulk_contacts Contacts
wpestate_crm_bulk_deals Deals
wpestate_crm_bulk_tasks Tasks
wpestate_crm_bulk_activities Activities

All four endpoints verify nonce via check_ajax_referer(‘wpestate_crm_nonce’, ‘security’).

Common Request Parameters

  • ids – array of integer IDs.
  • operation – whitelisted operation string (see per-entity list below).
  • value – optional value used by operations that need one (agent ID for bulk_assign_agent, stage name for bulk_change_stage, tag string for bulk_add_tag).

Response

JSON on success: { count: int } – number of rows affected.

Operations Matrix

Contacts

  • bulk_delete – iterates and calls wpestate_crm_delete_contact().
  • bulk_change_stage – updates lifecycle_stage on each row.
  • bulk_assign_agent – updates assigned_agent_id on each row.
  • bulk_add_tag – appends to tags CSV string, preventing duplicates.

Deals

  • bulk_delete
  • bulk_change_stage – updates stage (note: stage for deals vs status for other entities).

Tasks

  • bulk_delete
  • bulk_mark_complete – sets task_status=’Completed’ and completed_at=NOW().

Activities

  • bulk_delete only. Activities are append-only by design.

Helper Functions

Function Purpose
wpestate_crm_validate_entity_type($type) Whitelist check: contacts, leads, enquiries, deals, tasks
wpestate_crm_get_entity_table_info($type) Returns {table, pk} for the entity
wpestate_crm_bulk_delete($type, $ids) Generic delete using prepared IN (…) clause
wpestate_crm_bulk_update_status($type, $ids, $new_status) Generic status update with per-entity column mapping

SQL Safety

The bulk_delete helper builds IN clauses with parameter placeholders and calls $wpdb->prepare(). There is no direct interpolation of the ID array into SQL. The $ids input is cast to an integer array with array_map(‘absint’, $ids) before the prepare call.

Permissions

Each handler calls wpestate_crm_user_can($entity, ‘edit’) or wpestate_crm_user_can($entity, ‘delete’) depending on operation. Per-row ownership is also enforced for non-admins. Rows not owned by the user are silently skipped, so the affected count reflects reality.

Triggers and Side Effects

Bulk operations fire the same hooks as single-row operations:

  • Bulk delete fires wpestate_crm_after_delete_* per row.
  • Bulk change-stage fires wpestate_crm_after_update_* per row, which cascades into webhooks, automations, and HubSpot sync.

On large selections this can generate significant load. Consider wrapping bulk calls in remove_action() before and re-adding after if you need to suppress cascades for a specific import task.

Extending

  • Add your own operations by filtering the whitelist in a child plugin.
  • For custom entity types, extend the get_entity_table_info() map and register a new wp_ajax_wpestate_crm_bulk_{type} handler.
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