Skip to content

Conversation

@chickenn00dle
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

Closes https://linear.app/a8c/issue/NPPM-2524/bug-woo-member-commenting-module-allows-cancelled-memberships-to

This PR fixes an issue where readers with cancelled subscriptions are able to comment when the woo-member-commenting module is active and enabled.

We do this by filtering by status when checking a given readers subscriptions (Proposed by Adam Leone in the Linear task).

How to test the changes in this Pull Request:

  1. Set up the woo-member-commenting module (See instructions on that below
  2. Ensure commenting is enabled in WordPress settings
  3. As a non-subscribed reader, visit a restricted post associated with a membership plan and verify you are not able to comment on the post
  4. Subscribe to the relevant subscription to gain access
  5. Verify you can now comment
  6. Cancel the subscription as the reader so it is in pending-cancel state
  7. Verify you can still comment
  8. As admin, fully cancel the subscription
  9. As reader, verify you can no longer comment

Setting up woo member commenting:

  1. Run the following command: wp newspack optional-module activate woo-member-commenting
  2. Add the following snippet to wp-config.php:
const NP_WC_MEMBER_COMMENT_SETTINGS = [
  'membership_plan_slug'        => [''], // Slug(s) of membership plans. 
  'membership_purchase_post_id'     => 6, // Post id to a page/post with membershipt tease
  'membership_required_message' => "Become a member, why don't cha?",
];

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@chickenn00dle chickenn00dle requested a review from a team as a code owner January 14, 2026 20:27
Copilot AI review requested due to automatic review settings January 14, 2026 20:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restricts commenting access to users with active memberships by filtering membership statuses when checking user permissions for the woo-member-commenting module. The fix prevents users with cancelled subscriptions from commenting on restricted posts.

Changes:

  • Added status filtering to wc_memberships_get_user_memberships() call to only include active membership statuses
  • Explicitly passed user ID to the membership query function
Comments suppressed due to low confidence (1)

includes/optional-modules/class-woo-member-commenting.php:127

  • The caching logic is inverted. When $skip_cache is false and a cached value exists (not null), the function should return the cached value. However, the current condition returns the cached value when $skip_cache is true, which defeats the purpose of the skip parameter. The condition should be if ( ! $skip_cache && null !== $require_membership_to_comment ) to properly use cached values unless explicitly skipped.
		if ( $skip_cache || null !== $require_membership_to_comment ) {
			return $require_membership_to_comment;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chickenn00dle chickenn00dle added the [Status] Needs Review The issue or pull request needs to be reviewed label Jan 14, 2026
@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Jan 15, 2026
@chickenn00dle chickenn00dle merged commit a712266 into release Jan 15, 2026
14 checks passed
@chickenn00dle chickenn00dle deleted the hotfix/restrict-woo-membership-contents branch January 15, 2026 15:02
matticbot pushed a commit that referenced this pull request Jan 15, 2026
## [6.28.2](v6.28.1...v6.28.2) (2026-01-15)

### Bug Fixes

* **memberships:** restrict commenting to relevant statuses ([#4396](#4396)) ([a712266](a712266))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.28.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants