Anyone know a way to add the checkbox to opt-in to the login form?

I've tried adding:

  if ($form_id == 'user_login') {

    global $user;

    $form['simplenews'] = array(
      '#title' => t(''),
      '#description' => t('Sign me up for the club'),
      '#weight' => 4,
    );
    
    $form['simplenews']['simplenews-55'] = array(
      '#title' => t(''),
      '#type' => 'checkbox',
      '#description' => 'Sign me up for club',
      '#default_value' => 1,
      '#attributes' => array(
        'tabindex' => 3,
      ),
    );

    return;
  }

It adds the option to signup with a place for checkbox, but doesn't add the user to that specific newsletter. Anyone have a suggestion?

Comments

adamo’s picture

There's a module that does this: http://drupal.org/project/simplenews_register.

If you were to do it in your own form you would need to create a #submit callback function and have it execute simplenews_subscribe_user:

simplenews_subscribe_user($email_address, $newsletter_tid, $confirm);

$email_address = Subscriber's email.
$newsletter_tid = ID of newsletter
$confirm = TRUE to do email confirmation before activating subscription, FALSE if not.

sutharsan’s picture

Status: Active » Closed (fixed)

Check out the current 6.x-2.x-dev release.