You are here

function simplenews_confirm_multi_form_submit in Simplenews 7

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

File

includes/simplenews.subscription.inc, line 636
(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 $tid => $action) {
    if ($action == 'subscribe') {
      simplenews_subscribe_user($subscriber->mail, $tid, FALSE, 'website');
    }
    elseif ($action == 'unsubscribe') {
      simplenews_unsubscribe_user($subscriber->mail, $tid, 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');
}