-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix(memberships): remove managed flag on cancel or expire #192
Conversation
7c576da
to
8f70165
Compare
4c33ae1
to
101ce15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! So you're saying that if the membership is being permanently cancelled (not on hold) we should unlink them from the network, allowing it to be reactivated by a subscription purchase in another site. Makes sense!
Looking at the code, looks like the 3 update_post_meta
starting on line 87 can be deleted after your changes (and it makes sense, because we don't check if $user_membership
is a good object at that point)
I think it's worth adding a slightly bigger comment block explaining this reasoning there, so we can remember why we do this.
Not sure if it's also worth to add a note to the Membership saying it was unlinked from the other site?
101ce15
to
81f6156
Compare
81f6156
to
8e8a92e
Compare
Thanks for the review @leogermani! I've updated the PR with some more thorough comments, added a membership note, and am deleting all managed meta in 8e8a92e Let me know if these comments need to be more clear! |
$user_membership = wc_memberships_create_user_membership( | ||
[ | ||
'plan_id' => $local_plan_id, | ||
'user_id' => $user->ID, | ||
] | ||
); | ||
|
||
update_post_meta( $user_membership->get_id(), Memberships_Admin::NETWORK_MANAGED_META_KEY, true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean you can delete these 3 lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah whoops! Misread that. Updated in b0678eb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. Also snuck in a change to one of the comments relevant here: 299a9ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests well!
Hey @chickenn00dle, good job getting this PR merged! 🎉 Now, the 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! ❤️ |
Closes 1200550061930446-as-1209019125448157/f
This PR removes the network managed meta flag when a network membership is cancelled or expired, and resets network membership meta otherwise. This is so readers can resume a cancelled or expired subscription on another network site.
Right now, if a reader has an inactive membership on one site, then tries to rejoin the membership on another site, the managed meta flag and other meta data causes a plan mixup between nodes as in the asana task above.
Steps to test
wp newspack-network sync-all
tool.