Hi,

It would be nice if a module_invoke_all or drupal_alter can allow users to alter the mergevars values.
I hacked function mailchimp_lists_process_subscribe_form_choices into mailchimp_lists.module to add the "user language" like this:

    global $language;
    $lang = $language->language;
    if( !$is_anonymous && isset( $account->language ) && !empty( $account->language ) )
    	$lang = $account->language;
    $mergevars['MC_LANGUAGE'] = $lang;

With this code, user is registred to mailchimp with the language of it's Drupal account (or current language for anonymous users), and I can :

  1. fragment my subscribers by language
  2. add conditional if/else in mail templates based on language (*|IF:MC_LANGUAGE=en|* ... *|ELSE:|* ... *|END:IF|*) to send translated mails

If a

drupal_alter( 'mailchimp_lists_mergevars', $mergevars, $account );

can be added in mailchimp_lists_process_subscribe_form_choices function it would be helpful.

Comments

Shven’s picture

With a form_alter you can get the same result without hacking a contrib module.

function MODULENAME_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
  global $language;
  $form['mergevars']['MC_LANGUAGE'] = array(
    '#type' => 'hidden',
    '#default_value' => $language->language,
  );
}
amytswan’s picture

Status: Active » Closed (won't fix)

“And now our watch [for support of the 7.x-2.x version of the MailChimp module] has ended…” With the approaching deprecation of MailChimp’s API version 2.0, I’m sad to say we too must turn the page. This branch will become unsupported in early October and officially deprecated by the end of this year (2016).

Fret not! The 7.x-4.x and 8.x versions come highly recommended. Both are using Mailchimp’s new API 3.0 and are being actively maintained. If you find this issue still exists on either the 7.x-4.x or 8.x branches, let us know by opening a new ticket. “What is dead may never die, but rises again, harder and stronger!”