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