You are here

function simplenews_subscriptions_account_form in Simplenews 7.2

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

FAPI ACCOUNT subscription form.

Finally _account_ cases inject into hook_user and won't work on its own. Note that our basis is: drupal_get_form('user_profile_form', ...); and NOT: drupal_get_form('simplenews_subscriptions_account', ...);

see also user/user.module and user/user.pages.inc

See also

simplenews_subscriptions_account_form_validate()

simplenews_subscriptions_account_form_submit()

1 call to simplenews_subscriptions_account_form()
simplenews_form_user_profile_form_alter in ./simplenews.module
Implements hook_form_FORM_ID_alter().

File

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

Code

function simplenews_subscriptions_account_form(&$form, &$form_state, $subscriber) {
  $options = array();
  $default_value = array();

  // Get newsletters for subscription form checkboxes.
  // Newsletters with opt-in/out method 'hidden' will not be listed.
  foreach (simplenews_newsletter_get_visible() as $newsletter) {
    $options[$newsletter->newsletter_id] = check_plain($newsletter->name);
    $default_value[$newsletter->newsletter_id] = FALSE;
  }
  if ($subscriber) {
    $default_value = array_merge($default_value, $subscriber->newsletter_ids);
  }
  $form['subscriptions'] = array(
    '#type' => 'fieldset',
    '#description' => t('Select your newsletter subscriptions.'),
  );
  $form['subscriptions']['newsletters'] = array(
    '#type' => 'checkboxes',
    '#options' => $options,
    '#default_value' => $default_value,
  );
  $form['subscriptions']['#title'] = t('Current newsletter subscriptions');

  // if we don't override #validate, see user_profile_form_validate
  // adding an own #submit leads to the situation where drupal omits execution of user_profile_form_submit completely
  $form['#submit'][] = 'simplenews_subscriptions_account_form_submit';
}