diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 168853835..89f963825 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -354,13 +354,17 @@ static function postProcessCommon(&$params, &$formatted) { */ static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { $config = CRM_Core_Config::singleton(); + require_once 'CRM/Contact/BAO/Contact/Location.php'; + list($contributorDisplayName, + $contributorEmail + ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']); if (!empty($params['is_attach_receipt'])) { $receiptEmailType = !empty($config->receiptEmailType) ? $config->receiptEmailType : 'copy_only'; $receiptTask = new CRM_Contribute_Form_Task_PDF(); $receiptTask->makeReceipt($params['contribution_id'], $receiptEmailType, TRUE); //set encrypt password if (!empty($config->receiptEmailEncryption) && $config->receiptEmailEncryption) { - $receiptPwd = $form->userEmail; + $receiptPwd = $contributorEmail; if (!empty($receiptTask->_lastSerialId) && preg_match('/^[A-Za-z]{1,2}\d{8,9}$|^\d{8}$/', $receiptTask->_lastSerialId)) { $receiptPwd = $receiptTask->_lastSerialId; } @@ -456,8 +460,8 @@ static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { else { //offline contribution //Retrieve the name and email from receipt is to be send - $params['receipt_from_name'] = $form->userDisplayName; - $params['receipt_from_email'] = $form->userEmail; + $params['receipt_from_name'] = $contributorDisplayName; + $params['receipt_from_email'] = $contributorEmail; // assigned various dates to the templates $form->assign('receipt_date', CRM_Utils_Date::processDate($params['receipt_date'])); $form->assign('cancel_date', CRM_Utils_Date::processDate($params['cancel_date'])); @@ -517,11 +521,7 @@ static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { $params['receipt_text'] = CRM_Contribute_BAO_ContributionPage::tokenize($params['contact_id'], $params['receipt_text']); } $form->assign_by_ref('formValues', $params); - require_once 'CRM/Contact/BAO/Contact/Location.php'; require_once 'CRM/Utils/Mail.php'; - list($contributorDisplayName, - $contributorEmail - ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']); $form->assign('contactID', $params['contact_id']); $form->assign('contributionID', $params['contribution_id']); $form->assign('currency', $params['currency']); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 64fdb3a4d..cb30c05cb 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1705,15 +1705,6 @@ public function postProcess() { ); } - if ($this->_contactID) { - require_once 'CRM/Contact/BAO/Contact/Location.php'; - list($this->userDisplayName, - $this->userEmail - ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); - $this->assign('displayName', $this->userDisplayName); - $this->assign('contactID', $this->_contactID); - } - //send receipt mail. if ($contribution->id && CRM_Utils_Array::value('is_email_receipt', $formValues)) { $formValues['contact_id'] = $this->_contactID;