I'm running a D7 multilingual site and I want all registered users to be part of a required list, in order to send them a newsletter.
However I want to send the newsletter in the language set as their preference in their user profile.

I was thinking to use the standard language settings field of the user profile and merge it as a mailchmp field , to use a single list on Mailchimp.
But I don't see this field on the "merge fields" dropdown in the drupal mailchimp module configuration.

Any tips how to manage that ?
Thanks.

Comments

gabrielcardon’s picture

Same here. Mailchimp is perfect for all my needs, I just need my website to be able to use the various lists created depending on user language. Nowhere to be found in the list setup.

Khumbu’s picture

just came across this issue myself...any update on this matter?

edit: a workaround could be to add the language fields yourself (in the user profile) and disable the languge settings in a user profile through theming

marthinal’s picture

A few weeks ago I needed to say in any way to mailchimp send emails depending the user language by default. It was a D6 installation.

First I created different groups per language and then :

--- a/sites/all/modules/vanilla/mailchimp/mailchimp.module
+++ b/sites/all/modules/vanilla/mailchimp/mailchimp.module
@@ -924,6 +924,25 @@ function _mailchimp_load_user_list_mergevars($uid, $list_id, $mergevars) {
   $uservars = array(
       'EMAIL' => $account['mail']
   );
+  // Depending language we add the user to a group created previously on Mailchimp.
+  // By default 3 group options English, French and Spanish. 
+  // By default the name of the group is Languages so you need to create this group and options.
+  // When you send a campaign then you have to select by segment and send different campaigns 
+  // for each language.
+  switch ($account['language']) {
+    case 'en':
+      $lang = 'English';
+      break;
+    case 'es':
+      $lang = 'Spanish';
+      break;
+    case 'fr':
+      $lang = 'French';
+      break;
+    default:
+      $lang = 'English';
+  }     
+  $uservars['GROUPINGS'][] = array('name' => 'Languages', 'groups' => $lang);
   foreach ($mergevars as $mergevar) {
     if (!empty($list->mergevars[$mergevar['tag']]) && $key = $list->mergevars[$mergevar['tag']]) {
       $uservars[$mergevar['tag']] = $account[$key];

So when running cron job we add emails to mailchimpo depending default language selected on user profile.

Hope this info helps you one day.

titouille’s picture

Issue summary: View changes

Maybe this can help.
From the mailchimp API doc : http://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
In the "merge_vars" structure, you can use "MC_LANGUAGE" to add the preferred language of the user who subscribe to the list. A little modification can be made in the mailchimp_lists_process_subscribe_form_choices function (line 595 of mailchimp_list.module, 7.x (7.x-2.12 in my case)) :

    if (!$is_anonymous) {
      $mail = $account->mail;
      $selected = !empty($form_list['subscribe']);
      $mergevars = mailchimp_lists_load_user_mergevars($account, $list, $interest_groups);
    }
    else {
      $mail = $form_list['mergevars']['EMAIL'];
      $mergevars = $form_list['mergevars'];
      // Include interest groups if present:
      if (!empty($interest_groups)) {
        $mergevars['GROUPINGS'] = _mailchimp_lists_reformat_groupings($interest_groups);
      }
    }

+   global $language, $user;
+   $lang = $language->language;
+   if( !$is_anonymous && isset( $account->language ) && !empty( $account->language ) )
+   	$lang = $account->language;
+   $mergevars['MC_LANGUAGE'] = $lang;
  	
    $is_subscribed = mailchimp_is_subscribed($list->mc_list_id, $mail);

In my case, now user subscribed to list has the language parametred in it account or if anonymous, the global language value when he subscribe.

Hope this help.

joelpittet’s picture

A hook would be nice here to allow for these changes?

titouille’s picture

Yes joelpittet, I suggested a drupal_alter implementation here : https://www.drupal.org/node/2259809 but no answer about the proposition...

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!”