3

When Alice is creating and paying for a gift membership for Bob, she enters Bob's contact info and email address on the Membership Contribution form, so the emailed receipt goes to Bob (with a copy also going to the back office via the cc settings on the form) and Bob's email address becomes part of the contact record.

We have an optional custom field on the form where Alice can enter her own (different) email address and, ideally, receive a copy of the receipt as well.

in CiviCRM 4.6 we could make this happen by patching into postProcessMembership(), pulling the email address out of the form parameters, and tacking it onto the cc_receipt field that was passed to the sendMail function. However, in 4.7, the form handling is different enough that this method no longer works.

Is there a clean way to add a recipient to the emailed contribution receipt based on a value entered on the contribution form in CiviCRM 4.7?

thanks,

2

After some digging with debug_backtrace() to unravel the program flow within CiviCRM, I found this solution, which works:

(1) Implement hook_civicrm_postProcess(), and use it to get the giver email from $form->_submitValues. Stash it into a global variable.

(2) In CRM/Contribute/BAO/Contribution.php, patch function composeMessageArray() to append the giver email to $values['cc_receipt'] prior to the sendMail calls at the end of the function, then clear the global.

Obvious, this will need to be tested and reapplied with each upgrade of CiviCRM, but we already have a handful of such patches so one more is not too bad.

  • I'd love to see code snippets if you were willing to share. Did you do this in a separate module or hacking core files? – Laryn - CEDC.org May 25 '17 at 15:08
  • There was some of both. I couldn't find a way to avoid patching core, but I tried to make the patch as small and unobtrusive as possible. Happy to share the snippet, but it's longer than the comment box will allow. – bugfolder May 27 '17 at 16:10
  • Thanks! Could you add it as a gist on Github? gist.github.com – Laryn - CEDC.org May 30 '17 at 1:00
  • 1
1

I'm glad you found an answer that works for you! For others with this situation not using Drupal, you can install the Gift Memberships extension.

0

On Drupal you can configure a Gift Membership form with Webform CiviCRM - store the Contacts, their Relationship, the Membership, process the Monies, control the Email receipts - it's my go-to solution for Gift Memberships!

  • That looks pretty interesting, thanks!, but according to the docs here, wiki.civicrm.org/confluence/display/CRMDOC/…, it doesn't support PayPal, which we currently use ;o(. – bugfolder Jul 16 '16 at 2:42
  • It does work with PayPal! – KarinG - Semper IT Jul 16 '16 at 3:06
  • Well, not fully. I installed the module on a test site, created a form with PayPal as the payment method (we use Website Payments Standard), but upon submission, was redirected to the website of our credit card processor, not PayPal. And this seems to be an open issue: drupal.org/node/2756937 Despite that, it does look like a really useful and powerful module. – bugfolder Jul 17 '16 at 22:25
  • Ah yes - there is a bug in the current version that has stopped the PayPal button to work - but it does still work with PayPal Pro - so two options: revert to a prior version of webform_civicrm or upgrade to PayPal Pro (also a really good idea for many other reasons). – KarinG - Semper IT Jul 21 '16 at 12:49
  • Unfortunately, PayPal Pro has problems with our e-Commerce store, which is why we're on standard. Meanwhile, I found a relatively simple solution via patch, so I'll post it as a separate answer. – bugfolder Jul 22 '16 at 16:06

Your Answer

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

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