Fix set default for custom field on membership renewal form
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 11 Apr 2023 16:26:46 +0000 (17:26 +0100)
committerPradeep Nayak <pradpnayak@gmail.com>
Sat, 22 Apr 2023 18:30:36 +0000 (19:30 +0100)
CRM/Contribute/Form/Contribution/Main.php

index 9819e8276c08a261535ceaaf09498406a88a83a1..79a50557dcd14c62c825a706af01db1a75737153 100644 (file)
@@ -281,7 +281,11 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       //set custom field defaults
       foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
-          if (!isset($this->_defaults[$name])) {
+          // check if the custom field is on a membership, we only want to load
+          // defaults for membership custom fields here, not contact fields
+          if (!isset($this->_defaults[$name])
+            && !CRM_Core_BAO_CustomGroup::checkCustomField($customFieldID, ['Membership'])
+          ) {
             CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults,
               $entityId, CRM_Profile_Form::MODE_REGISTER
             );