Skip to:
Content
Pages
Categories
Search
Top
Bottom

Expired member still getting subscription notifications


  • sleestak
    Participant

    @sleestak

    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!

Viewing 10 replies - 1 through 10 (of 10 total)

  • Robin W
    Moderator

    @robin-w

    what membership plugin are you using ?


    sleestak
    Participant

    @sleestak

    I am using PMPro for membership.

    Thanks!


    Mike Witt
    Participant

    @mike80222

    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!


    sleestak
    Participant

    @sleestak

    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.


    Robin W
    Moderator

    @robin-w

    I’m playing with some code, give me a while to work it out !!


    Mike Witt
    Participant

    @mike80222

    > 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!


    Robin W
    Moderator

    @robin-w

    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 :

    Action and Filter Hooks

    I am guessing that pmpro_membership_post_membership_expiry is 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

    Code Snippets


    Robin W
    Moderator

    @robin-w

    @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.


    sleestak
    Participant

    @sleestak

    Wow, this is great! Will give it a try. Thank you so much!


    Mike Witt
    Participant

    @mike80222

    @robin-w,

    … 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

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar