From 5ff6bb3171551e28da9826a3274d6745c7c8fd79 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Thu, 31 Dec 2015 12:59:43 +0530 Subject: [PATCH] CRM-17723 -- Inherited Membership not created from Online Contribution Page --- CRM/Contribute/BAO/Contribution.php | 7 +++++++ CRM/Member/BAO/Membership.php | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 3582ef87a0..3c1906917a 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4319,8 +4319,15 @@ LIMIT 1;"; //we might be renewing membership, //so make status override false. $membershipParams['is_override'] = FALSE; + $membershipParams['reset'] = TRUE; civicrm_api3('Membership', 'create', $membershipParams); + // unset/format unwanted keys + $removeKeys = array('id', 'contact_id', 'reset'); + $membershipParams = array_diff_key($membershipParams, array_flip($removeKeys)); + if (!empty($membershipParams['status_id']) && is_string($membershipParams['status_id'])) { + $membershipParams['status_id'] = array_search($membershipParams['status_id'], CRM_Member_PseudoConstant::membershipStatus()); + } //update related Memberships. CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $membershipParams); } diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 62d397c05d..6c9efce8c0 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -401,7 +401,11 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { $transaction->commit(); - self::createRelatedMemberships($params, $membership); + $reset = FALSE; + if (!empty($params['reset'])) { + $reset = TRUE; + } + self::createRelatedMemberships($params, $membership, $reset); // do not add to recent items for import, CRM-4399 if (empty($params['skipRecentView'])) { -- 2.25.1