improve newsletter subcription result values
This commit is contained in:
parent
221f9c72f3
commit
90f27f70c7
1 changed files with 7 additions and 5 deletions
|
@ -526,7 +526,7 @@ 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']['newsletter_double_opt_in']
|
||||
$result_values['newsletter_double_opt_in']
|
||||
= (bool) $profile->getAttribute('newsletter_double_opt_in')
|
||||
? 'true'
|
||||
: 'false';
|
||||
|
@ -555,7 +555,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
|||
]
|
||||
)['visibility'] == 'Public Pages';
|
||||
if (!in_array($group_id, $group_memberships, FALSE) && $is_public_group) {
|
||||
$result_values['newsletter'][][$group_id] = civicrm_api3(
|
||||
$result = civicrm_api3(
|
||||
'MailingEventSubscribe',
|
||||
'create',
|
||||
[
|
||||
|
@ -564,9 +564,12 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
|||
'contact_id' => $contact_id,
|
||||
]
|
||||
);
|
||||
$subscription = CRM_Utils_Array::first($result['values']);
|
||||
$subscription['group_id'] = $group_id;
|
||||
$result_values['newsletter_subscriptions'][] = $subscription;
|
||||
}
|
||||
elseif ($is_public_group) {
|
||||
$result_values['newsletter'][] = $group_id;
|
||||
$result_values['newsletter_group_ids'][] = $group_id;
|
||||
}
|
||||
}
|
||||
// If requested, add contact to newsletter groups defined in the profile.
|
||||
|
@ -584,8 +587,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
|||
'contact_id' => $contact_id,
|
||||
]
|
||||
);
|
||||
|
||||
$result_values['newsletter'][] = $group_id;
|
||||
$result_values['newsletter_group_ids'][] = $group_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue