Expired member still getting subscription notifications
-
I have a paid membership WordPress (5.7.2) site using bbPress. I have it set for users to be able to subscribe to forums/topics. However, when their membership expires, they are still getting email notifications of their subscriptions. How can I prevent this?
Thanks!
-
what membership plugin are you using ?
I am using PMPro for membership.
Thanks!
For what it’s worth, I’m using MemberPress and I have to unsubscribe people from bbPress (and BuddyPress) notifications by hand when they leave. I would love to come up with a better scheme!
Good to know. I don’t see how to unsubscribe them from notifications via the admin console at all. I guess I could do it via the database.
I’m playing with some code, give me a while to work it out !!
> I don’t see how to unsubscribe them from notifications via the admin console
I think the page I’m going to, in order to unsubscribe them, is created by BuddyPress.
I bet Robin will come up with something good!BOTH
You will need to test the below, as I don’t use either plugin on any forum site.
PM PRO
for PMpro you have the following hooks :
I am guessing that
pmpro_membership_post_membership_expiryis the correct hook.so the code you need is :
add_action( 'pmpro_membership_post_membership_expiry', 'rew_remove_subscriptions') ; function rew_remove_subscriptions ($user_id=0) { $forums = bbp_get_user_subscribed_forum_ids ($user_id) ; foreach ($forums as $forum=>$id) { bbp_remove_user_subscription ($user_id, $id, 'post' ) ; } $topics = bbp_get_user_subscribed_topic_ids ($user_id) ; foreach ($topics as $topic=>$id) { bbp_remove_user_subscription ($user_id, $id , 'post' ) ; } }MEMBERPRESS
for Memberpress you have the following links
https://docs.memberpress.com/article/325-action-hooks-in-memberpress
I am guessing that ‘mepr-event-subscription-stopped`
is the correct one, but you might need to query with memberpress
so for memberpress you would have
add_action( 'mepr-event-subscription-stopped', 'rew_remove_subscriptions') ; function rew_remove_subscriptions ($event) { $subscription = $event->get_data(); $user_id = $subscription->user(); $forums = bbp_get_user_subscribed_forum_ids ($user_id) ; foreach ($forums as $forum=>$id) { bbp_remove_user_subscription ($user_id, $id, 'post' ) ; } $topics = bbp_get_user_subscribed_topic_ids ($user_id) ; foreach ($topics as $topic=>$id) { bbp_remove_user_subscription ($user_id, $id , 'post' ) ; } }BOTH
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
@mike80222 looking again, your code might need
$subscription = $event->get_data(); $user = $subscription->user(); $user_id = something more to get the ID ;but I’d suggest you raise a ticket or look through the documentation.
Wow, this is great! Will give it a try. Thank you so much!
… and anyone who happens to look at this and is running MemberPress.
Yes, there is more to do with MP. MP Members may or may not have actual “Subscriptions.” They can also just have memberships without what MP calls subscriptions. These membership can go “inactive.” But, unfortunately, that can happen *temporarily* if their credit card needs to be updated.
None-the-less, your code examples are quite valuable!
In the unlikely event that anyone else here is running MP and is interested in this, please chime in here (or otherwise contact me). I would love to compare notes on this and related things.
-Mike
- You must be logged in to reply to this topic.