People table

Since 2.0.0, LH CRM keeps one network-wide table linking posts to the people they concern: {base_prefix}lh_crm_people (lhero_lh_crm_people on LocalHero). It records who an enquiry is from, and is the planned home for the members a committee note is about. The code is in includes/lh-crm-people-class.php (LH_Crm_people_class).

Schema

ColumnTypeDescription
blog_idbigint unsignedSite the post belongs to
post_idbigint unsignedThe post on that site
user_idbigint unsignedThe person
relationvarchar(20)enquirer (enquiries) or subject (member notes). Filterable via lh_crm_return_relations.

Primary key (blog_id, post_id, user_id, relation), plus a user_site (user_id, blog_id, relation) index for “everything about this person on this site”. A post can have several people for one relation.

Site scoping

Every row carries its blog_id, and every method of the API reads and writes for the current site only; code that needs another site switches to it first. This is what stops one organisation seeing another’s records. Reads are cached in the lh_crm_people group, invalidated by a last-changed key on every write.

Install and backfill

The table is created with dbDelta() on init (and the hourly lh_crm_wakeup cron) whenever the network option lh_crm_people_schema_version differs from LH_Crm_people_class::schema_version(), never keyed on the plugin version. On each site, a one-off backfill then copies every existing enquiry’s post_author into the table as its enquirer (auto-drafts excluded) and records lh_crm_people_backfill_version. Until a site’s backfill has run, enquiry code there falls back to post_author, which is what it meant before 2.0.0. On LocalHero the backfill ran on 17 November 2026 for the four sites with enquiries.

Cleanup and account merges

EventHookEffect
Post deleted (not trashed)before_delete_postIts rows on that site are removed
Site deletedwp_delete_siteAll the site’s rows are removed
User removed from a sitedeleted_userTheir rows on that site move to the user their content was reassigned to, or are removed
User deleted from the networkwpmu_delete_userAll their rows are removed
Accounts merged with LH User Identitylh_user_identity_merge_handlers (handler lh_crm_people)One network-wide update moves the secondary account’s rows to the primary; where both were on the same post the duplicate is removed. The merge plan reports the number of rows.

Why a table

post_author can only hold one person and also has to mean who created the post, so an enquiry entered by staff for someone else showed the wrong enquirer. Post meta cannot be queried efficiently per person across a network. A single network table keeps every link to a person in one place, which makes account merges one update and allows a per-person view across enquiries and notes.