strangerstudios / pmpro-network-subsite

Manage memberships at the network’s main site (the primary domain of the network) and provide/restrict access on subsites in the network.
https://www.paidmembershipspro.com/add-ons/pmpro-network-membership/
3 stars 14 forks source link

Removed users do not lose membership #23

Open dparker1005 opened 3 years ago

dparker1005 commented 3 years ago

In core PMPro, we remove a user's membership level when they are deleted; however on a multisite, "deleting" a user from the WP Users page on a subsite does not run the delete hooks. This means that users can have membership levels on a site that they are no longer a user on.

To fix this, we need to additionally remove a user's membership level on the "remove_user_from_blog" hook: https://developer.wordpress.org/reference/hooks/remove_user_from_blog/

dparker1005 commented 3 years ago

As a workaround, this should be fixed by adding the following line to a custom plugin: add_action('remove_user_from_blog', 'pmpro_delete_user');

Maybe this should go into core. @ideadude @andrewlimaza

andrewlimaza commented 9 months ago

I think this is okay, I'm happy with having this as a gist for now as removing a user from a site doesn't delete them and I'm worried that running this would affect their subscriptions on other sites.