Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-3151

civicrm_contact_membership_create doesn't properly create memberships for related contact

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Blocker
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Component/s: CiviMember
    • Labels:
      None

      Description

      When creating a membership for a contact that is, say, a member of a household, the API doesn't properly create the memberships for the related contacts. The problems is that in the API call, the API uses CRM_Member_BAO_Membership::checkMembershipRelationship that returns an array of the related contacts. The returned array is a set of "contact_id" => "relationship_type_id" pairs, and the API code expects just "index" => "contact_id" pairs.

      The code in the API currently looks like this:

      <code>
      foreach ( $relatedContacts as $contactId )

      { $params['contact_id' ] = $contactId; $params['owner_membership_id'] = $membershipBAO->id; unset( $params['id'] ); CRM_Member_BAO_Membership::create( $params, CRM_Core_DAO::$_nullArray ); }

      </code>

      And it should look like this:

      <code>
      foreach ( $relatedContacts as $contactId => $relationTypeId )

      { $params['contact_id' ] = $contactId; $params['owner_membership_id'] = $membershipBAO->id; unset( $params['id'] ); CRM_Member_BAO_Membership::create( $params, CRM_Core_DAO::$_nullArray ); }

      </code>

        Attachments

          Activity

            People

            • Assignee:
              sunil Sunil Pawar
              Reporter:
              zagrev Steve Betts
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 2 days
                2d
                Remaining:
                Remaining Estimate - 2 days
                2d
                Logged:
                Time Spent - Not Specified
                Not Specified