You are here

function simplenews_block_form_submit in Simplenews 7

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_block_form_submit()
  2. 6.2 includes/simplenews.subscription.inc \simplenews_block_form_submit()
  3. 6 simplenews.module \simplenews_block_form_submit()
  4. 7.2 includes/simplenews.subscription.inc \simplenews_block_form_submit()
1 string reference to 'simplenews_block_form_submit'
simplenews_block_form in includes/simplenews.subscription.inc
FAPI BLOCK subscription form.

File

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

Code

function simplenews_block_form_submit($form, &$form_state) {
  $tid = $form['#tid'];
  $account = simplenews_load_user_by_mail($form_state['values']['mail']);
  $confirm = simplenews_require_double_opt_in($tid, $account);
  switch ($form_state['values']['action']) {
    case 'subscribe':
      simplenews_subscribe_user($form_state['values']['mail'], $tid, $confirm, 'website');
      if ($confirm) {
        drupal_set_message(t('You will receive a confirmation e-mail shortly containing further instructions on how to complete your subscription.'));
      }
      else {
        drupal_set_message(t('You have been subscribed.'));
      }
      break;
    case 'unsubscribe':
      simplenews_unsubscribe_user($form_state['values']['mail'], $tid, $confirm, 'website');
      if ($confirm) {
        drupal_set_message(t('You will receive a confirmation e-mail shortly containing further instructions on how to cancel your subscription.'));
      }
      else {
        drupal_set_message(t('You have been unsubscribed.'));
      }
      break;
  }
}