From 4432060d0586e2f9259a2867eccca1f7a1de802e Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Tue, 11 Jun 2024 13:00:12 +0200 Subject: [PATCH] add a condition to check if the value is 1 --- api/v3/TwingleDonation/Submit.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/v3/TwingleDonation/Submit.php b/api/v3/TwingleDonation/Submit.php index d307424..9ebbfb6 100644 --- a/api/v3/TwingleDonation/Submit.php +++ b/api/v3/TwingleDonation/Submit.php @@ -533,6 +533,7 @@ function civicrm_api3_twingle_donation_Submit($params) { if ( (bool) $profile->getAttribute('newsletter_double_opt_in') && isset($params['newsletter']) + && 1 == $params['newsletter'] && is_array($groups = $profile->getAttribute('newsletter_groups')) ) { $group_memberships = array_column( @@ -573,6 +574,7 @@ function civicrm_api3_twingle_donation_Submit($params) { } elseif ( isset($params['newsletter']) + && 1 == $params['newsletter'] && is_array($groups = $profile->getAttribute('newsletter_groups')) ) { foreach ($groups as $group_id) { @@ -592,6 +594,7 @@ function civicrm_api3_twingle_donation_Submit($params) { // If requested, add contact to postinfo groups defined in the profile. if ( isset($params['postinfo']) + && 1 == $params['postinfo'] && is_array($groups = $profile->getAttribute('postinfo_groups')) ) { foreach ($groups as $group_id) { @@ -609,6 +612,7 @@ function civicrm_api3_twingle_donation_Submit($params) { // (see issue #83) if ( isset($params['donation_receipt']) + && 1 == $params['donation_receipt'] && is_array($groups = $profile->getAttribute('donation_receipt_groups')) ) { foreach ($groups as $group_id) {