You are here

function simplenews_subscriptions_account_form in Simplenews 6.2

Same name and namespace in other branches
  1. 7.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_user in ./simplenews.module
Implementation of hook_user().

File

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

Code

function simplenews_subscriptions_account_form(&$form_state, $account) {
  $subscription = simplenews_get_subscription($account);
  $form = array();
  $options = array();
  $default_value = array();

  // Get newsletters for subscription form checkboxes.
  // Newsletters with opt-in/out method 'hidden' will not be listed.
  foreach (simplenews_get_newsletters(variable_get('simplenews_vid', '')) as $newsletter) {
    $options[$newsletter->tid] = check_plain($newsletter->name);
    $default_value[$newsletter->tid] = FALSE;
  }
  $form['subscriptions'] = array(
    '#type' => 'fieldset',
    '#description' => t('Select your newsletter subscriptions.'),
  );
  $form['subscriptions']['newsletters'] = array(
    '#type' => 'checkboxes',
    '#options' => $options,
    '#default_value' => array_merge($default_value, (array) $subscription->tids),
  );
  $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';
  return $form;
}