Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: limit purchase of a network membership #169

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

leogermani
Copy link
Contributor

@leogermani leogermani commented Dec 13, 2024

Limit subscription purchase if it grants access to a membership the user already has access to in another site of the Network.

This is the same thing as #137 (instructions number 4 on #138) but for logged out readers.

Here's how to test it:

  • Having two sites in a Newspack Network installation
  • On site A and B, create a membership plan with the same "Network ID"
  • In each site, create a subscription product that grants access to these membership plans
  • Make sure the network is in sync ( wp newspack-network process-webhooks in all Nodes and then wp newspack-network sync-all in all nodes)
  • On site A, as a new reader, purchase the subscription
  • Make sure the network is in sync again
  • Visit site B, not logged in
  • Attempt to purchase the subscription, using the same email used in site A
  • You should not be allowed to make the purchase and should see a message saying that you already have that membership in another site:

image


  • To see the specific tasks where the Asana app for GitHub is being used, see below:
    • 0-as-1207352955560208

@leogermani leogermani self-assigned this Dec 17, 2024
@leogermani leogermani marked this pull request as ready for review December 17, 2024 13:45
@leogermani leogermani requested a review from a team as a code owner December 17, 2024 13:45
if ( $network_active_subscription ) {
$error_message = sprintf(
/* translators: %s: Site URL */
__( "You can't buy this subscription because you already have it active on %s", 'newspack-network' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this updated error message, but just wanted to share why I removed the site name initially. Since this is for logged out readers, its possible for someone to input another persons email address here, in which case they'd learn about where another person's subscription exists.

This is probably not a big deal, but wanted to share just in case.

@leogermani leogermani changed the title feat: limit purchase of a network membership WIP feat: limit purchase of a network membership Dec 18, 2024
Copy link
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

It works!

image

I agree with @chickenn00dle on the messaging here. I don't think it's great that we're disclosing that information but also think it's a very edge case.

@leogermani
Copy link
Contributor Author

@chickenn00dle @miguelpeixe , thanks for the reviews! I've updated the copy with help from @thomasguillot and @kmwilkerson to

Oops! You already have a subscription on another site in this network that grants you access to this site as well. Please log in using the same email address.

@leogermani leogermani merged commit deb2683 into trunk Dec 20, 2024
4 checks passed
@leogermani leogermani deleted the feat/limit-network-membership-purchase-logged-out branch December 20, 2024 15:40
Copy link

Hey @leogermani, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Jan 10, 2025
# [2.4.0-alpha.1](v2.3.4...v2.4.0-alpha.1) (2025-01-10)

### Bug Fixes

* **content-distribution:** post insertion hook and additional meta for incoming post event ([#173](#173)) ([48df13c](48df13c))
* load text domain on init hook ([#171](#171)) ([01fb89c](01fb89c))

### Features

* content distribution - experimental ([#168](#168)) ([dc837d8](dc837d8))
* **content-distribution:** add CLI command for distribute post ([#159](#159)) ([7a43b86](7a43b86)), closes [#155](#155) [#156](#156) [#157](#157) [#160](#160) [#165](#165)
* **content-distribution:** canonical url ([#177](#177)) ([5ca60ce](5ca60ce))
* **content-distribution:** capability and admin page ([#176](#176)) ([5285285](5285285))
* **content-distribution:** control distribution meta and prevent multiple dispatches ([#170](#170)) ([e76a2dc](e76a2dc))
* **content-distribution:** editor plugin for distribution ([#167](#167)) ([e10aef4](e10aef4))
* **content-distribution:** handle status changes ([#166](#166)) ([4af5da1](4af5da1))
* **content-distribution:** log incoming post errors ([#182](#182)) ([74c9119](74c9119))
* **content-distribution:** posts column ([#178](#178)) ([8e07640](8e07640))
* **content-distribution:** reserved taxonomies ([#174](#174)) ([a2c54d2](a2c54d2))
* **content-distribution:** sync comment and ping statuses ([#179](#179)) ([90c5425](90c5425))
* **content-distribution:** sync post meta ([#163](#163)) ([353a3d8](353a3d8))
* **event-log:** collapse data ([#180](#180)) ([956219d](956219d))
* limit purchase of a network membership ([#169](#169)) ([deb2683](deb2683))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.4.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jan 20, 2025
# [2.4.0](v2.3.4...v2.4.0) (2025-01-20)

### Bug Fixes

* **content-distribution:** post insertion hook and additional meta for incoming post event ([#173](#173)) ([48df13c](48df13c))
* load text domain on init hook ([#171](#171)) ([01fb89c](01fb89c))

### Features

* content distribution - experimental ([#168](#168)) ([dc837d8](dc837d8))
* **content-distribution:** add CLI command for distribute post ([#159](#159)) ([7a43b86](7a43b86)), closes [#155](#155) [#156](#156) [#157](#157) [#160](#160) [#165](#165)
* **content-distribution:** canonical url ([#177](#177)) ([5ca60ce](5ca60ce))
* **content-distribution:** capability and admin page ([#176](#176)) ([5285285](5285285))
* **content-distribution:** control distribution meta and prevent multiple dispatches ([#170](#170)) ([e76a2dc](e76a2dc))
* **content-distribution:** editor plugin for distribution ([#167](#167)) ([e10aef4](e10aef4))
* **content-distribution:** handle status changes ([#166](#166)) ([4af5da1](4af5da1))
* **content-distribution:** log incoming post errors ([#182](#182)) ([74c9119](74c9119))
* **content-distribution:** posts column ([#178](#178)) ([8e07640](8e07640))
* **content-distribution:** reserved taxonomies ([#174](#174)) ([a2c54d2](a2c54d2))
* **content-distribution:** sync comment and ping statuses ([#179](#179)) ([90c5425](90c5425))
* **content-distribution:** sync post meta ([#163](#163)) ([353a3d8](353a3d8))
* **event-log:** collapse data ([#180](#180)) ([956219d](956219d))
* limit purchase of a network membership ([#169](#169)) ([deb2683](deb2683))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.4.0 🎉

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants