function _mailchimp_subscribe_user in Mailchimp 5
Same name and namespace in other branches
- 5.2 mailchimp.module \_mailchimp_subscribe_user()
- 6.2 mailchimp.module \_mailchimp_subscribe_user()
- 6 mailchimp.module \_mailchimp_subscribe_user()
- 7 mailchimp.module \_mailchimp_subscribe_user()
Subscribe the given user to the given list if he/she is not already subscribed
2 calls to _mailchimp_subscribe_user()
File
- ./
mailchimp.module, line 691
Code
function _mailchimp_subscribe_user($list, $merge_vars, $message = true, $q = NULL) {
if ($q || ($q = _mailchimp_get_api_object())) {
$double_optin = variable_get('mailchimp_list_' . $list['id'] . '_doublein', 0);
if (_mailchimp_is_subscribed($list['id'], $merge_vars['EMAIL'], $q)) {
$success = $q
->listUpdateMember($list['id'], $merge_vars['EMAIL'], $merge_vars);
}
else {
$success = $q
->listSubscribe($list['id'], $merge_vars['EMAIL'], $merge_vars, 'html', $double_optin);
if ($message && $success && $double_optin) {
drupal_set_message(t('You have chosen to subscribe to %list. An email will be sent to your address. Click the link in the email to confirm the subscription.', array(
'%list' => $list['name'],
)));
}
else {
if ($message && $success) {
drupal_set_message(t('You have subscribed to %list.', array(
'%list' => $list['name'],
)));
}
}
}
}
return $success;
}