Answers.Body: <p>After some digging with debug_backtrace() to unravel the program flow within CiviCRM, I found this solution, which works:</p>
  
  <p>(1) Implement hook_civicrm_postProcess(), and use it to get the giver email from $form->_submitValues. Stash it into a global variable.</p>
  
  <p>(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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-25T15:08:32.113Z
Answers.Text: 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?
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-27T16:10:25.730Z
Answers.Text: 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.
Answers.UserDisplayName: bugfolder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-30T01:00:33.583Z
Answers.Text: Thanks! Could you add it as a gist on Github? https://gist.github.com/
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-05T21:59:37.233Z
Answers.Text: Added: https://gist.github.com/bugfolder/b8189c26f4f1df4becd69e677a89bff4
Answers.UserDisplayName: bugfolder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-22T16:09:57.820Z
Answers.LastActivityDate: 2016-07-22T16:09:57.820Z
Answers.UserDisplayName: bugfolder
Answers.Body: <p>I'm glad you found an answer that works for you!  For others with this situation not using Drupal, you can install the <a href="https://civicrm.org/extensions/gift-memberships" rel="nofollow">Gift Memberships</a> extension.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-21T17:12:33.477Z
Answers.LastActivityDate: 2016-08-21T17:12:33.477Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>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!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-16T02:42:22.410Z
Answers.Text: That looks pretty interesting, thanks!, but according to the docs here, https://wiki.civicrm.org/confluence/display/CRMDOC/Webform+CiviCRM+Integration, it doesn't support PayPal, which we currently use ;o(.
Answers.UserDisplayName: bugfolder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-16T03:06:59.213Z
Answers.Text: It does work with PayPal!
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-17T22:25:04.150Z
Answers.Text: 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: https://www.drupal.org/node/2756937
  
  Despite that, it does look like a really useful and powerful module.
Answers.UserDisplayName: bugfolder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-21T12:49:48.273Z
Answers.Text: 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).
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-22T16:06:50.650Z
Answers.Text: 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.
Answers.UserDisplayName: bugfolder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-15T02:03:22.973Z
Answers.LastActivityDate: 2016-07-15T02:03:22.973Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>thanks,</p>
  
Tags: <civicontribute><civimember><email>
Title: For gift memberships, send email receipt to the giver
ThreadText: # For gift memberships, send email receipt to the giver
  
  (Asked by: username_0 on 2016-07-14)
  
  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,
  
  **Tags:** civicontribute, civimember, email
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2016-07-22. Score: 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.
  
  > **Comments:**
  > **username_1**: 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?  
  > **username_0**: 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.  
  > **username_1**: Thanks! Could you add it as a gist on Github? https://gist.github.com/  
  > **username_0**: Added: https://gist.github.com/username_0/b8189c26f4f1df4becd69e677a89bff4  
  
  ---
  
  ### Answer by username_2 on 2016-08-21. Score: 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](https://civicrm.org/extensions/gift-memberships) extension.
  
  
  ---
  
  ### Answer by username_3 on 2016-07-15. Score: 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!
  
  > **Comments:**
  > **username_0**: That looks pretty interesting, thanks!, but according to the docs here, https://wiki.civicrm.org/confluence/display/CRMDOC/Webform+CiviCRM+Integration, it doesn't support PayPal, which we currently use ;o(.  
  > **username_3**: It does work with PayPal!  
  > **username_0**: 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: https://www.drupal.org/node/2756937  Despite that, it does look like a really useful and powerful module.  
  > **username_3**: 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).  
  > **username_0**: 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.  
  
  ---
  
  