Posted by nedwardss on June 9, 2009 at 10:11pm
Jump to:
| Project: | MailChimp |
| Version: | 6.x-1.1 |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed |
Issue Summary
Hello and thanks for a great module.
I was wondering if there is a way to get the preferred email format as an available merge variable? I've set up the field in the profile in drupal but the merge variable for that field is not available on admin/settings/mailchimp page (but the rest are). I saw that people were have problems with the interest groups not mapping. Perhaps this is related?
Thanks again.
Comments
#1
Seconded. I'd love to see preferred email format as well.
#2
This cannot be implemented as a merge variable since email format is not an avaialble merge variable from MailChimp. It's a separate parameter, which would have to be added to all subscription fields, assuming an admin wants it as an option. So we can leave in the queue as I imagine that could be useful, but it would be an additional setting and a new field added with each subscription form.
#3
Just add a new option to the admin settings for Preferred Format just like the Interest Groups option.
$form['mailchimp_user_settings']['mailchimp_prefered_format_user_forms'] = array('#type' => 'checkbox',
'#title' => t('Show Prefered Format on Registration and Account Forms'),
'#description' => t('If set, users will be able to select their prefered email format when signing up for newsletters.'),
'#default_value' => variable_get('mailchimp_prefered_format_user_forms',0),
);
Then update the _mailchimp_subscribe_user function, adding an argument at the end for $email_pref = 'html'. Also change the following two lines in that same function.
$success = $q->listUpdateMember($list->id, $email, $merge_vars, $email_pref);and
$success = $q->listSubscribe($list->id, $email, $merge_vars, $email_pref, $double_optin, TRUE);
After that it's just a matter of passing through the value of $email_pref in the functions that call _mailchimp_subscribe_user.
For my uses I just needed to add the option to choose format. The other options provided by the module were unnecessary since there will be no registered users who are not administrators.
That should be a good enough start on adding this functionality to the module though. Maybe later when I finish with what I'm doing I'll look at fully integrating what I did and submit it here for approval.
Oh, forgot to share the function for adding the element to forms.
function _mailchimp_prefered_format_element($q, $list_id, $format = 'html', $is_subscribed = FALSE) {
$element = array();
$element['prefered_format_' . $list_id] = array(
'#type' => 'radios',
'#title' => t('Prefered format'),
'#options' => array(
'html' => 'HTML',
'text' => 'Text',
'mobile' => 'Mobile',
),
'#default_value' => $format,
);
return $element;
}