Email address not stored
Created by: tanyabouman
I have a grant application page which takes the email address of the applicant. On the confirmation page, the email shows up properly. However, in the CRM, it gets stored as "1", rather than the actual email address. The confirmation email also attempts to send to 1@[mydomain.com].
The grant application sends two individual contact email addresses in $params, email-Primary and email-1, to createProfileContact from CiviCRM Core. https://github.com/civicrm/civicrm-core/blob/master/CRM/Contact/BAO/Contact.php. email-Primary contains the correct email address and email-1 comes from a hidden field whose default value is 1. Inside the profile contact creation, there is a re-formatting of the array that puts email-Primary and email-1 in the same place (formatProfileContactParams). Since email-Primary gets put in first, email-1 overrides it.
I made a quick fix by inserting the line $params['email-1'] = CRM_Utils_Array::value('email-Primary', $params);
just before the call to createProfileContact.
I assume that there is a better way to fix the problem, perhaps by removing email-1? Why is email-1 there in the first place? Or maybe formatProfileContactParams isn't doing the correct thing?
WordPress: 4.9.8 CiviCRM: 5.2.2 Grant Applications: 1.6.1