feat(integrations): add content gate metadata#4605
feat(integrations): add content gate metadata#4605chickenn00dle wants to merge 4 commits intotrunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Reader Activation Sync contact metadata for Content Gate access so ESP/CRM contacts can be annotated with whether they can bypass custom content gates and what grants that access.
Changes:
- Implement
Reader_Activation\Sync\Contact_Metadata\Content_Gateto computeContent_AccessandContent_Access_Sourcefrom published content gates’ custom access rules. - Expose
User_Gate_Access::evaluate_gate_for_user()publicly for reuse by the metadata class. - Add unit tests covering basic content-gate metadata behavior (primarily email domain rules).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
includes/reader-activation/sync/contact-metadata/class-content-gate.php |
Computes and returns Content Gate metadata fields for sync, including source derivation from per-rule evaluation. |
includes/content-gate/class-user-gate-access.php |
Makes evaluate_gate_for_user() public so other components can reuse detailed evaluation results. |
tests/unit-tests/content-gate/class-content-gate-metadata.php |
Adds unit tests validating metadata output for no gates, invalid user, and email-domain rule scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
includes/reader-activation/sync/contact-metadata/class-content-gate.php
Outdated
Show resolved
Hide resolved
includes/reader-activation/sync/contact-metadata/class-content-gate.php
Outdated
Show resolved
Hide resolved
includes/reader-activation/sync/contact-metadata/class-content-gate.php
Outdated
Show resolved
Hide resolved
5f3c4c1 to
be9c88e
Compare
| // No custom access gates configured — user is not restricted. | ||
| if ( empty( $custom_access_gates ) ) { | ||
| return [ | ||
| 'Content_Access' => 'Yes', |
There was a problem hiding this comment.
Hmmm.. if there's no content gate, I think we should return either No or an empty string here
There was a problem hiding this comment.
Sounds good. I went with the empty string so its easy to distinguish between when there is no gate configured and when there is but the reader doesn't have access: 3b8de35
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Implements the
Content_Gatemetadata class for reader activation sync, adding two fields that track whether a reader has access to gated content and what grants that access."Yes","No", or empty — whether the reader can bypass any published content gate with custom access rules. Empty when no content gates are configured."domain"(email domain rule), or"group"(institutional access). Empty when Content_Access is"No"or empty.Makes
User_Gate_Access::evaluate_gate_for_user()public so the metadata class can reuse its detailed per-rule evaluation results.Fixes
get_access_source_labelsto only include product names the user has actually purchased, rather than all products configured on the gate rule. UsesAccess_Rules::has_active_subscription()to check each product individually, covering both individual and group subscriptions.Closes NPPD-1390
Test plan
wp-config.php:Content_Access = "No"andContent_Access_Source= empty (since the reader has no subscriptions)Content_Access = "Yes"andContent_Access_Source= only the purchased product name (e.g.,"Basic Plan"), NOT both productsContent_Access_Sourcenow includes both product names"domain"when the reader's email matches"group"when the reader matchesContent_Accessis empty with empty source🤖 Generated with Claude Code