So I've actually stumbled upon a couple small notices while working on things. The first two occur when you submit a form that has an email field and the MailChimp field is tied to that email field, but you don't actually click the "Subscribe" checkbox for MailChimp. Basically in my use, I have a contact form where you can opt to sign up for the newsletter and if you do, it should use the email address field you provide in the form.

All I think we need is a check on the MailChimp field that will only run the code referenced if that checkbox is checked.

Notice: Undefined variable: email_address in webform_mailchimp_webform_submission_insert() (line 151 of /sites/all/modules/custom/webform_mailchimp/webform_mailchimp.module).
Notice: Undefined variable: email_address in webform_mailchimp_webform_submission_insert() (line 125 of /sites/all/modules/custom/webform_mailchimp/webform_mailchimp.module).

In light of the above notices, I opted to go with the option of having MailChimp field create the email field for me. I got the second notice below:

Notice: Undefined variable: size in _webform_render_mailchimp() (line 210 of /sites/all/modules/custom/webform_mailchimp/webform_mailchimp.inc).

Easy enough to fix, just commented out line 211 defining the size of the text field.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blackdog’s picture

Status: Active » Postponed (maintainer needs more info)

I don't think this is an issue anymore. Can you confirm?

jnettik’s picture

Status: Postponed (maintainer needs more info) » Active

I'm still getting the error:

Notice: Undefined variable: email_address in webform_mailchimp_webform_submission_insert() (line 126 of /home/afcishow/public_html/sites/all/modules/contrib/webform_mailchimp/webform_mailchimp.module).

I think the problem is with the the if statement below starting on line 38.

  // Need to know if we should look for our own email field or another.
  if ($field['extra']['use_existing_email_field'] != 'mailchimp_field') {
    // If using existing field, check if the checkbox was checked
    if ($submission->data[$key]['value'][0] == 1) {
      // Loop through components again to find our email field
      foreach($node->webform['components'] AS $key2 => $field2) {
        if ($field2['form_key'] == $field['extra']['use_existing_email_field']) {
          // Get the form value
          $email_address = $submission->data[$key2]['value'][0];
        }
      }
    }
  }
  // We have our own email field
  else {
    $email_address = $submission->data[$key]['value'][0];
  }

It looks like you're checking that I'm not using a generated email field, which I'm not. Then checks if the checkbox was checked, which it wasn't. So the $email_address never gets created. I think there needs to be some way for users to submit an email address field without subscribing to the newsletter.

jnettik’s picture

Status: Active » Needs review
FileSize
503 bytes

I uploaded a small patch with a fallback for $email_address. Seems to work for what I'm doing.

SchwebDesign’s picture

thx this helped fix this issue for me as well!

blackdog’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.