Digital Sovereignty for everyone

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

Column Type Description
blog_id bigint unsigned Site the post belongs to
post_id bigint unsigned The post on that site
user_id bigint unsigned The person
relation varchar(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.

  • LH_Crm_people_class::add( $post_id, $user_id, $relation ) and set( $post_id, $user_ids, $relation ) (replaces the list; empty clears it)
  • get_user_ids( $post_id, $relation ) and get_post_ids( $user_id, $relation )
  • For enquiries: LH_Crm_enquiry_post_type_class::get_enquirer_id(), set_enquirer_id() and get_enquiry_ids_for_enquirer()

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

Event Hook Effect
Post deleted (not trashed) before_delete_post Its rows on that site are removed
Site deleted wp_delete_site All the site’s rows are removed
User removed from a site deleted_user Their rows on that site move to the user their content was reassigned to, or are removed
User deleted from the network wpmu_delete_user All their rows are removed
Accounts merged with LH User Identity lh_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.

If you like this plugin please consider making a donation to further development

Install LHero.org

lhero.org

Open it straight from your home screen, full screen and quicker to load.

  1. Tap the Share button . If you cannot see it, tap ••• first.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add.
  1. Tap the browser menu â‹®.
  2. Tap Install app or Add to Home screen.
  1. In the menu bar, choose File, then Add to Dock.

Use your browser's menu to install this site or add it to your home screen.