You are here

function simplenews_confirm_multi_form_submit in Simplenews 7.2

Same name and namespace in other branches
  1. 7 includes/simplenews.subscription.inc \simplenews_confirm_multi_form_submit()

File

includes/simplenews.subscription.inc, line 686
(Un)subscription and (un)subscription confirmation

Code

function simplenews_confirm_multi_form_submit($form, &$form_state) {
  $subscriber = $form_state['values']['subscriber'];
  foreach ($subscriber->changes as $newsletter_id => $action) {
    if ($action == 'subscribe') {
      simplenews_subscribe($subscriber->mail, $newsletter_id, FALSE, 'website');
    }
    elseif ($action == 'unsubscribe') {
      simplenews_unsubscribe($subscriber->mail, $newsletter_id, FALSE, 'website');
    }
  }

  // Clear changes.
  $subscriber->changes = array();
  simplenews_subscriber_save($subscriber);
  drupal_set_message(t('Subscription changes confirmed for %user.', array(
    '%user' => $subscriber->mail,
  )));
  $form_state['redirect'] = variable_get('site_frontpage', 'node');
}