Thanks for the handy module. It's easy to set up, except for one thing: When you use the Mailchimp Lists module to add a subscription field/form to the user registration page, the field settings only let you select a single newsletter. And when this is rendered as a form on the user registration page, the label for the checkbox is shown as "Subscribe", not as the newsletter name. E.g.:

Newsletters
[] Subscribe

How do you get more than one newsletter to appear in this fieldset? The use case is to let new users subscribe to one or more newsletters when they register. So ideally, the fieldset would look like this:

Newsletters
[] Daily Digest
[] News You Can Use
[] Awesome Newsletter #3

I see that you can create and add additional fields, but that results in multiple fieldsets like the following, which is poor UI:

Daily Digest
[] Subscribe

News You Can Use
[] Subscribe

Any thoughts? Am I doing something wrong? Thanks!

Comments

aasarava’s picture

In case anyone is interested, I came up with a workaround like this:

1. I created a new field for each newsletter.
2. I used the following code in my own module to remove the fieldsets that are around each individual field, and to change "Subscribe" label to be the name of each newsletter.
3. I used the fieldgroup module to group the fields together in a single fieldset where I can control the label and description.

function MYMODULE_field_widget_form_alter(&$element, &$form_state, $context) {
  $field = $context['field'];
  if ($field['type'] == 'mailchimp_lists_subscription') {
    $mailchimp_id = $field['settings']['mc_list_id'];
    $lists = mailchimp_get_lists(array($mailchimp_id));
    $list = $lists[$mailchimp_id];
    $name = check_plain($list['name']);

    // Remove fieldset around element.
    $element['#type'] = 'div';
    // Change "Subscribe label" to name of actual newsletter.
    $element['subscribe']['#title'] = $name;
  }
}

The result is a nice group as follows:

Newsletters
[] Daily Digest
[] News You Can Use
[] Awesome Newsletter #3

BabaYaga64’s picture

I'm also not able to add multiple newsletters to one signup form. I'd like to utilize your patch, but I was wondering if you could clarify on step 1. "created a new field for each newsletter." Did you create new fields in the code or in the signup form? If it is in the code, can you please specify which file? Thanks for your help.

BabaYaga64’s picture

Category: Support request » Feature request

Aasarava, I am also seeing each newsletter showing up in its own field set, with its own subscribe button. I think this is the default way that the module works. Perhaps your workaround is helpful for other users? I'm changing your support request to a feature request.

aasarava’s picture

@BabaYaga64, it has been a while since I did it, but I believe the fields are created on the signup form. For example, if you want users to select one or more newsletters on the user registration form, you'd go to Configuration > People > Account Settings > Manage Fields and create the fields there for each newsletter.

ruscoe’s picture

Status: Active » Closed (won't fix)

We're going to be ending support for the 7.x-3.x branch due to the upcoming deprecation of the v2.0 MailChimp API. If you're still interested in this feature, please feel free to reopen for the 7.x-4.x branch.