From de51957768af55a5ab15967287bccd67cd37ff2b Mon Sep 17 00:00:00 2001 From: Jason Coleman Date: Mon, 6 Apr 2020 21:27:12 -0400 Subject: [PATCH] Don't remove them, if we're about to add them back in. --- includes/groups.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/groups.php b/includes/groups.php index ea0370e..f230377 100644 --- a/includes/groups.php +++ b/includes/groups.php @@ -44,8 +44,13 @@ function pmpro_bp_set_member_groups( $level_id, $user_id, $cancel_level ) { if ( ! empty( $old_groups_invite ) ) { foreach ( $old_groups_invite as $group_id ) { - groups_uninvite_user( $user_id, $group_id ); - // remove user from group as well + // Don't remove them, if we're about to add them back in. + if ( in_array( $group_id, $new_groups_invite ) ) { + continue; + } + + // Uninvite and remove from group. + groups_uninvite_user( $user_id, $group_id ); groups_leave_group( $group_id, $user_id ); } }