diff --git a/CRM/Twingle/Form/Profile.php b/CRM/Twingle/Form/Profile.php index 5f18715..3491125 100644 --- a/CRM/Twingle/Form/Profile.php +++ b/CRM/Twingle/Form/Profile.php @@ -329,7 +329,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form { $this->add( 'checkbox', // field type - 'double_opt_in', // field name + 'newsletter_double_opt_in', // field name E::ts('Use Double-Opt-In for newsletter'), // field label FALSE, // is not required array() @@ -339,7 +339,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form { 'select', // field type 'newsletter_groups', // field name E::ts('Sign up for newsletter groups'), // field label - static::getNewsletterGroups($this->profile->getAttribute('double_opt_in')), // list of options + static::getNewsletterGroups($this->profile->getAttribute('newsletter_double_opt_in')), // list of options FALSE, // is not required array('class' => 'crm-select2 huge', 'multiple' => 'multiple') ); @@ -556,7 +556,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form { $values['name'] = 'default'; } $this->profile->setName($values['name']); - $this->profile->setAttribute('double_opt_in', isset($values['double_opt_in'])); + $this->profile->setAttribute('newsletter_double_opt_in', isset($values['newsletter_double_opt_in'])); foreach ($this->profile->getData() as $element_name => $value) { if (isset($values[$element_name])) { $this->profile->setAttribute($element_name, $values[$element_name]); diff --git a/CRM/Twingle/Profile.php b/CRM/Twingle/Profile.php index e0afe35..9c86f1a 100644 --- a/CRM/Twingle/Profile.php +++ b/CRM/Twingle/Profile.php @@ -221,7 +221,7 @@ class CRM_Twingle_Profile { 'membership_type_id', 'membership_type_id_recur', 'membership_postprocess_call', - 'double_opt_in' + 'newsletter_double_opt_in' ), // Add payment methods. array_keys(static::paymentInstruments()), @@ -294,7 +294,7 @@ class CRM_Twingle_Profile { 'custom_field_mapping' => NULL, 'membership_type_id' => NULL, 'membership_type_id_recur' => NULL, - 'double_opt_in' => NULL, + 'newsletter_double_opt_in' => NULL, ) // Add contribution status for all payment methods. + array_fill_keys(array_map(function($attribute) { diff --git a/api/v3/TwingleDonation/Submit.php b/api/v3/TwingleDonation/Submit.php index d0f9061..19217b6 100644 --- a/api/v3/TwingleDonation/Submit.php +++ b/api/v3/TwingleDonation/Submit.php @@ -486,8 +486,8 @@ function civicrm_api3_twingle_donation_Submit($params) { // If usage of double opt-in is selected, use MailingEventSubscribe.create to add contact to newsletter groups // defined in the profile - $result_values['newsletter']['double_opt_in'] = ($profile->getAttribute('double_opt_in')) ? 'true' : 'false'; - if ($profile->getAttribute('double_opt_in') && + $result_values['newsletter']['newsletter_double_opt_in'] = ($profile->getAttribute('newsletter_double_opt_in')) ? 'true' : 'false'; + if ($profile->getAttribute('newsletter_double_opt_in') && !empty($params['newsletter']) && !empty($groups = $profile->getAttribute('newsletter_groups'))) { $group_memberships = array_column(civicrm_api3('GroupContact', 'get', array ( diff --git a/templates/CRM/Twingle/Form/Profile.tpl b/templates/CRM/Twingle/Form/Profile.tpl index 3e6a07e..83dc4cb 100644 --- a/templates/CRM/Twingle/Form/Profile.tpl +++ b/templates/CRM/Twingle/Form/Profile.tpl @@ -209,13 +209,13 @@
{$form.double_opt_in.label} | -{$form.double_opt_in.html} | +{$form.newsletter_groups.label} | +{$form.newsletter_groups.html} |
{$form.newsletter_groups.label} | -{$form.newsletter_groups.html} | +{$form.newsletter_double_opt_in.label} | +{$form.newsletter_double_opt_in.html} |