Skip to content

Commit

Permalink
fix(memberships): remove managed flag on cancel or expire
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Jan 17, 2025
1 parent 120b759 commit 8f70165
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ public function update_membership() {
return;
}

$user_membership->update_status( $this->get_new_status() );
$status = $this->get_new_status();
$is_managed = get_post_meta( $user_membership->get_id(), Memberships_Admin::NETWORK_MANAGED_META_KEY, true );
// If the membership is being cancelled or expired, remove the network managed flag.
if ( in_array( $status, [ 'cancelled', 'expired' ], true ) && $is_managed ) {
delete_post_meta( $user_membership->get_id(), Memberships_Admin::NETWORK_MANAGED_META_KEY );
// Otherwise, if the membership is not managed, set the network managed flag.
} elseif ( ! $is_managed ) {
update_post_meta( $user_membership->get_id(), Memberships_Admin::NETWORK_MANAGED_META_KEY, true );
}
$user_membership->update_status( $status );
$user_membership->add_note(
sprintf(
// translators: %s is the site URL.
Expand Down

0 comments on commit 8f70165

Please sign in to comment.