function simplenews_subscription_manager_form_submit in Simplenews 6
Same name and namespace in other branches
- 5 simplenews.module \simplenews_subscription_manager_form_submit()
1 string reference to 'simplenews_subscription_manager_form_submit'
- simplenews_subscription_manager_form in ./
simplenews.subscription.inc - Menu callback: Generates the subscription form for users.
File
- ./
simplenews.subscription.inc, line 54 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscription_manager_form_submit($form, &$form_state) {
switch ($form_state['values']['op']) {
case t('Update'):
// We first subscribe, then unsubscribe. This prevents deletion of subscriptions
// when unsubscribed from the
arsort($form_state['values']['newsletters'], SORT_NUMERIC);
foreach ($form_state['values']['newsletters'] as $tid => $checked) {
if ($checked) {
simplenews_subscribe_user($form_state['values']['mail'], $tid, FALSE);
}
else {
simplenews_unsubscribe_user($form_state['values']['mail'], $tid, FALSE);
}
}
drupal_set_message(t('The newsletter subscriptions for %mail have been updated.', array(
'%mail' => $form_state['values']['mail'],
)));
break;
case t('Subscribe'):
foreach ($form_state['values']['newsletters'] as $tid => $checked) {
if ($checked) {
simplenews_subscribe_user($form_state['values']['mail'], $tid);
}
}
drupal_set_message(t('You will receive a confirmation email shortly containing further instructions on how to complete your subscription.'));
break;
case t('Unsubscribe'):
foreach ($form_state['values']['newsletters'] as $tid => $checked) {
if ($checked) {
simplenews_unsubscribe_user($form_state['values']['mail'], $tid);
}
}
drupal_set_message(t('You will receive a confirmation email shortly containing further instructions on how to complete the unsubscription process.'));
break;
}
}