I have a webform where our users can add new contacts to CiviCRM. This form creates an activity record. And this form should create a membership for these contacts. The membership has some custom fields; let's say field Reason and has values "Good, Bad, Audit" and a Referral field that contains the name of a person.
So far, this is standard CiviCRM Webform. I can create the new contact record, create their membership, and populate the membership custom field with the option that the user selects.
Now, this webform allows users to select existing contacts. Those existing contacts already have a membership, and already have a value in that Reason field.
My goal is that for existing contacts, IF the user selects "Audit" for the reason field, then the membership does not update. So the membership record, membership type, membership dates, Referral custom field and Reason custom field should stay the same as what they were previously. But this only happens if the Reason custom field is selected as "Audit". For any other reason field value, the membership should update as normal.
What I have tried:
- I can't figure out how to do this using webform conditionals. Is there a way? I would need to somehow capture the contact's membership field values before the user submits the contact.
- Could I do this with a webform hook? In that case, which hook should I be looking at so that it processes before the webform/civicrm integration?
- I looked at using CiviRules, with the Webform CiviRules integration, but this seems to fire after the webform is submitted.