From: Pradeep Nayak Date: Tue, 11 Apr 2023 16:26:46 +0000 (+0100) Subject: Fix set default for custom field on membership renewal form X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4ca313524ecc38f3790254a7462e39b134543fe5;p=civicrm-core.git Fix set default for custom field on membership renewal form --- diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 9819e8276c..79a50557dc 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -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 );