+ $update = TRUE;
+ //Update Membership status if there is no other completed contribution associated with the membership.
+ $relatedContributions = CRM_Member_BAO_Membership::getMembershipContributionId($membership->id, TRUE);
+ foreach ($relatedContributions as $contriId) {
+ if ($contriId == $contributionId) {
+ continue;
+ }
+ if (CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contriId) === 'Completed') {
+ $update = FALSE;
+ }
+ }
+ if ($membership && $update) {