Occasionally, we end up with a single contact that has two membership records (e.g., an old expired one and a newer current one). I would like to programmatically merge the two memberships cleanly, so that, for example, the remaining membership gets the oldest start date, the current membership type, all contributions are retained, etc. Have browsed Dedupe.php looking for a call that might do this, but to no avail. Any suggestions?
2 Answers
Currently there's no support for what you're describing built in to CiviCRM. You could implement this with API calls in an extension. If you do, please consider submitting it to the extensions directory!
-
I would do this, but it's not clear what API calls would enable this. Looking in the API Explorer, for entity Membership, there's no option to "merge" (or anything that looks like that). Commented Apr 28, 2015 at 11:12
-
1You will have to create the api to merge... which will use the api to update the first membership, move all the contributions from the second to the first membership and then delete the second membership. Commented May 8, 2015 at 15:04
I’ve started to work on a patch for CiviCRM (as it’s not that simple to implement this as an extension). The work-in-progress PR is available here. Comments and feedbacks are welcome ;)
Olivier;
-
The PR github.com/civicrm/civicrm-core/pull/11298 if I am reading right solves the merging of memberships between contacts, which is great! but not within a contact. Commented Apr 14, 2022 at 22:34