0

I'm trying to create inherited memberships in the civicrm_post hook. I feel like there is something wrong with the api itself. The API doesn't even recognize my only membership id in the database.

Here is the one membership record in the db:

enter image description here

When I try to create the API create statement, I can't even select the only ID in the database, which is 4:

enter image description here

My actual code looks like this:

enter image description here

The resulting logs from that function are here: enter image description here

When submitting the form, I get no error on the front end and you can see the log showing no error as well, but nothing gets submitted to the membership table. I'd also like to note that in another hook (the civicrm_postProcess hook), I am successfully taking values from a contribution form and creating relationships between an organization and the primary member submitting the form and the additional members provided in the form values.

The main question is, How can I add new, inherited memberships to the members table with code?

This question is based on part of an extension I am making to try to solve this problem:

Membership for Group of people. One payer

I'm using Joomla! 3.9.16 CiviCRM 5.23.3

Extra Information / Edits:

Here is my relationship table, showing that there are relationships to the primary members already:

enter image description here

Here is my relationship_type table:

enter image description here

Here is my membership_type:

enter image description here

Here is my organization contact from the contact that holds the parent membership:

enter image description here

Here is the individual contact from the contact table that I am trying to give an inherited membership:

enter image description here

Edit - Membership Type Screenshot:

enter image description here

enter image description here

Relationship Types :

enter image description here

6
  • The related memberships are also automatically created/deleted by civicrm. They are based on the relationship of the primary member. So for example when we have a family membership the head of the household, household members are also a member when the household has the membership. So it might be that your membership gets deleted by core civicrm as there is no relationship in your membership type or with the primary member. – Jaap Jansma - CiviCooP Apr 16 '20 at 14:36
  • @Jaap I added some more images to show that I do have relationships with the primary member. What did you mean by relationship in "membership type"? – Kurt Leadley Apr 16 '20 at 18:49
  • When you configure your membership type (and only when creating a new one) you can select which related people should get a related membership. This is based on a relationship. See also the documentation: docs.civicrm.org/user/en/latest/membership/defining-memberships/… – Jaap Jansma - CiviCooP Apr 20 '20 at 7:06
  • @JaapJansma-CiviCooP When I look at my settings for Membership Type, I can see that I have it assigned to "Group Member of" already. Which is a custom relationship. Maybe I need to change that since I need a parent and then child membership types? – Kurt Leadley Apr 20 '20 at 7:41
  • @JaapJansma-CiviCooP I added three more screenshots. I thought I had correctly implemented what you mentioned in the last comment you sent to me. Is there anything obviously wrong? – Kurt Leadley Apr 20 '20 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.