Update trash_users_subscriptions() to properly delete subscriptions in HPOS environments. #520
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When a user/subscriber is deleted, we hook onto the
delete_user
hook and delete all subscriptions that belong to this user. This function was still usingwp_post_delete()
which doesn't work in a HPOS environment resulting in subscriptions remaining without a customer attached.This PR updates the
trash_users_subscriptions()
function and replaces thewp_post_delete( $id )
method with$subscription->delete( true )
so work in both HPOS & WP Posts environments.How to test this PR
trunk
you will notice the subscription still exists without a customer and the parent order will have a note saying the subscription was deleted.Product impact