function party_subscription_settings_edit_form_submit in Party 8.2
Submit party subscription settings form
File
- modules/
party_simplenews/ party_subscription_settings.api.inc, line 188 - Helper functions etc for the subscription settings
Code
function party_subscription_settings_edit_form_submit($form, &$form_state, &$attached_entity, $party) {
$hash = 'party_subscription_settings:' . $attached_entity->subscription_settings_id;
$emails = party_get_all_emails($party);
$values =& $form_state['values'][$hash];
$field_ref = $values['field_ref'];
$mail = $emails[$field_ref];
// We first subscribe, then unsubscribe. This prevents deletion of subscriptions
// when unsubscribed from the
arsort($values['subscriptions']['newsletters'], SORT_NUMERIC);
foreach ($values['subscriptions']['newsletters'] as $tid => $checked) {
if ($checked) {
// We may want to override this to make sure we get the right field ref
simplenews_subscribe_user($mail, $tid, FALSE, 'website');
}
else {
simplenews_unsubscribe_user($mail, $tid, FALSE, 'website');
}
}
drupal_set_message(t('The newsletter subscriptions for %party <%email> have been updated.', array(
'%party' => $party->label,
'%email' => $mail,
)));
}