3

When I attach a multi-record custom field group to a profile for contribution pages, Civi only allows visitors to enter the fields once. I've read through jira a bit and see that the capability isn't there currently. Is there a simplified example showing how to use API v3 (preferably PHP, but any method is fine) in a way that adds a multi-record custom field group at the end of a contribution (i.e. after payment processing is complete)?

4
  • If using Drupal, you might be able to achieve this using a webform and the webform_civicrm integration module
    – Graham
    Commented Apr 1, 2015 at 8:03
  • @Graham that would work - why not add it as an answer
    – Coleman
    Commented Apr 1, 2015 at 12:43
  • Webform_civicrm would solve so many problems for this client. Unfortunately they're on Wordpress, and it's a pro bono gig so I'm trying to find a way to solve their need with the smallest amount of custom code. The examples are a bit too generic for me to grasp; they show the mechanics of an API call, but each example is isolated and lacks context so I'm seeing the "how" but not the "why" or "when".
    – Nicholai
    Commented Apr 1, 2015 at 12:56
  • My impression is that they can enter more than once but they have to be submitted one at a time. I have a site where everyone is walking and they have been submitting their miles each week through a normal form in Joomla.
    – Elin
    Commented Apr 3, 2015 at 18:20

1 Answer 1

1

To clarify this scenario: you must be talking about muti-record contact custom data and not contribution custom data (which only supports single-records currently).

I recommend you use hook_civicrm_postProcess to insert code to store the data on form submission. This code inside your implementation of the hook should use the CustomValue API to save the data. You'll find documentation and examples of how to use it in the API explorer.

2
  • I think I'm getting confused because the hook examples don't use the API. Conversely, the API examples don't appear to be implemented via a Civi hook (it always seems to be within Drupal modules). The example in your link writes straight SQL, and other hook examples in the docs prefer to skip the API and use BAO and DAO directly.
    – Nicholai
    Commented Apr 1, 2015 at 13:19
  • 2
    The hook docs could use updating.
    – Coleman
    Commented Apr 1, 2015 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.