[buddypress-trac] [BuddyPress Trac] #9327: Enhancement Request: Add `privacy` column to `bp_activity` for per-item visibility control

buddypress-trac noreply at wordpress.org
Fri Feb 20 17:47:28 UTC 2026


#9327: Enhancement Request: Add `privacy` column to `bp_activity` for per-item
visibility control
-------------------------+------------------------------
 Reporter:  indigetal    |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Activity     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------
Changes (by prbot):

 * keywords:   => has-patch


Comment:

 ''This ticket was mentioned in
 [https://github.com/buddypress/buddypress/pull/438 PR #438] on
 [https://github.com/buddypress/buddypress/ buddypress/buddypress] by
 [https://github.com/indigetal indigetal].''
 Add `privacy` as a core activity field across schema, model persistence,
 query APIs, helper write paths, and REST serialization/input handling, so
 addons can rely on a single native storage/query contract instead of post-
 save double writes.

 Trac ticket: https://buddypress.trac.wordpress.org/ticket/9327

 Schema + upgrade gating:
 - `bp_core_install_activity_streams()` now defines:
   - `privacy varchar(75) NOT NULL DEFAULT 'public'`
   - `KEY privacy (privacy)`
 - Bump BuddyPress DB version in `class-buddypress.php` (`13906` ->
 `13907`) so schema upgrades run through normal update flow.

 Activity model (`BP_Activity_Activity`):
 - Add class property default: `privacy = 'public'`.
 - Hydrate `privacy` in `populate()` and both `get_activity_data()` paths
 (cached + uncached) to keep object shape consistent.
 - Add save-time filter hook:
   - `bp_activity_privacy_before_save`
 - Persist `privacy` in both SQL branches:
   - UPDATE includes `privacy = %s`
   - INSERT includes `privacy` column/value
 - Extend `get()`:
   - new arg default: `'privacy' => false`
   - optional WHERE constraint via `a.privacy IN (...)`
   - allow ordering by `privacy` in `order_by` whitelist.

 Write-path parity (`bp_activity_add` + helpers):
 - `bp_activity_add()`:
   - add parsed arg default `'privacy' => 'public'`
   - assign `$activity->privacy` before save
   - docblock updated
 - `bp_activity_post_update()`:
   - accept/pass `privacy` through helper payload to `bp_activity_add()`
   - docblock updated
 - Groups helper path:
   - `groups_record_activity()` default includes `privacy`
   - `groups_post_update()` accepts/passes `privacy`
   - docblock updated

 Query allowlist:
 - Add `'privacy'` to `BP_Activity_Query::$db_columns` so `filter_query`
 clauses using `column => 'privacy'` are validated and applied.

 REST activity endpoint:
 - `prepare_item_for_response()` now includes `privacy` in response data.
 - `prepare_item_for_database()` accepts/propagates request `privacy` (with
 fallback to existing activity value on updates).
 - `get_item_schema()` adds `privacy` property (string) with contexts and
 sanitize callback (`sanitize_text_field`).

 Verification performed:
 - `php -l` passed for all touched PHP files.
 - Local site runtime checks confirmed:
   - direct `bp_activity_add()` persists privacy
   - helper branches (`bp_activity_post_update`, groups update flow)
 persist privacy
   - `BP_Activity_Activity::get( [ 'privacy' => ... ] )` filters correctly
   - `filter_query` with `column => privacy` works
   - REST create/update branches persist + return `privacy`
 - Note: local environment had downgraded DB-version state during testing;
 runtime behavior checks still passed after schema parity adjustments.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9327#comment:3>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list