Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • M Membership - archive
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Incidents
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Development
  • Membership - archive
  • Issues
  • #19

Closed (moved)
(moved)
Open
Created Nov 29, 2019 by wouterh@wouterh💬

Related membership gets deleted upon updating owner membership via API

I would like to give several people a membership, linked to 1 payment

  • person A: membership (+ contribution)
  • person B: membership (related to membership person A)
$contact_a = 2;
$contact_b = 3;

$contribution = civicrm_api3('Contribution', 'create', [
  'financial_type_id' => 2,
  'contact_id' => (int) $contact_a,
  'contribution_status_id' => 2,
  'total_amount' => 50,
  'is_pay_later' => 1,
]);

$main_membership = civicrm_api3('Membership', 'create', [
  'contact_id' => (int) $contact_a,
  'membership_type_id' => 1,
  'status_id' => 5,
  'skipStatusCal' => 1,
]);

$part_membership = civicrm_api3('Membership', 'create', [
  'contact_id' => (int) $contact_b,
  'owner_membership_id' => $main_membership['id'],
  'membership_type_id' => 1,
  'status_id' => 5,
  'skipStatusCal' => 1,
]);

$memb_payment = civicrm_api3('MembershipPayment', 'create', [
  'membership_id' => (int) $main_membership['id'],
  'contribution_id' => (int) $contribution['id'],
]);

This seems correct, person A gets a membership & contribution, person B gets a membership related to the membership of person A.

As soon as I process the membership payment via the API the contribution is complete and the membership for person A becomes active, BUT the membership for person B is deleted !?

$complete = civicrm_api3('Contribution', 'completetransaction', [
	'id' => 9, 
	'is_email_receipt' => 0
]);

I have simplified the operation to only the membership registrations:

$contact_a = 2;
$contact_b = 3;

$main_membership = civicrm_api3('Membership', 'create', [
  'contact_id' => (int) $contact_a,
  'membership_type_id' => 1,
  'status_id' => 5,
  'skipStatusCal' => 1,
]);

$part_membership = civicrm_api3('Membership', 'create', [
  'contact_id' => (int) $contact_b,
  'owner_membership_id' => $main_membership['id'],
  'membership_type_id' => 1,
  'status_id' => 5,
  'skipStatusCal' => 1,
]);

And if I then set the membership of person A to "New" the membership of person B is deleted !?

$new = civicrm_api3('Membership', 'create', [
  'id' => 39,
  'status_id' => "New",
]);

The problem therefore lies somewhere with the update of the membership of person A.

Does anyone have an idea?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking