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

Duplicate Inherited memberships caused by updating relationship via api in a post hook

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.3.3
    • Fix Version/s: 4.5.5
    • Component/s: CiviMember
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      If a individual contact inherits a membership via relationship such as 'Employee/Employer' and you try to update the relationship in a post-hook a duplicate membership is created. That is the individual will receive 2 inherited memberships instead of one.

      The site I am developing on is 4.3.3 but I would assume that this happens in other versions.

      Explained in detail in forum topic: http://forum.civicrm.org/index.php/topic,29822.new.html#new

      Example of post hook code:
      function mymodule_civicrm_post( $op, $objectName, $objectId, &$objectRef ){
      if($op=='create'){
      if ($objectName=='Relationship')

      { $params = array( 'version' => 3, 'sequential' => 1, 'id' => $objectId, 'contact_id_a' => $objectRef->contact_id_a, 'contact_id_b' => $objectRef->contact_id_b, 'is_permission_a_b' => 1, ); $result = civicrm_api('Relationship', 'create', $params); }

      }

      }

        Attachments

          Activity

            People

            • Assignee:
              colemanw Coleman Watts
              Reporter:
              jackrabbithanna Mark Hanna
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: