function mailchimp_subscribe_process in Mailchimp 7.3
Same name and namespace in other branches
- 8 mailchimp.module \mailchimp_subscribe_process()
- 7.5 mailchimp.module \mailchimp_subscribe_process()
- 7.4 mailchimp.module \mailchimp_subscribe_process()
- 2.x mailchimp.module \mailchimp_subscribe_process()
Wrapper around Mailchimp_Lists::subscribe().
Return value
bool True on success.
See also
Mailchimp_Lists::subscribe()
1 call to mailchimp_subscribe_process()
- mailchimp_subscribe in ./
mailchimp.module - Subscribe a user to a MailChimp list in real time or by adding to the queue.
2 string references to 'mailchimp_subscribe_process'
- mailchimp_subscribe in ./
mailchimp.module - Subscribe a user to a MailChimp list in real time or by adding to the queue.
- mailchimp_update_local_cache in ./
mailchimp.module - Updates the local cache for a user as though a queued request had been processed.
File
- ./
mailchimp.module, line 395 - Mailchimp module.
Code
function mailchimp_subscribe_process($list_id, $email, $merge_vars = NULL, $double_optin = FALSE, $format = 'html', $update_existing = TRUE, $replace_interests = TRUE, $confirm = TRUE) {
$result = FALSE;
try {
$mcapi = mailchimp_get_api_object();
if (!$mcapi) {
throw new MailchimpException('Cannot subscribe to list without MailChimp API. Check API key has been entered.');
}
$result = $mcapi->lists
->subscribe($list_id, array(
'email' => $email,
), $merge_vars, $format, $double_optin, $update_existing, $replace_interests, $confirm);
if (isset($result['email'])) {
module_invoke_all('mailchimp_subscribe_user', $list_id, $email, $merge_vars);
// Clear user cache, just in case there's some cruft leftover:
mailchimp_cache_clear_member($list_id, $email);
watchdog('mailchimp', '@email was subscribed to list @list.', array(
'@email' => $merge_vars['EMAIL'],
'@list' => $list_id,
), WATCHDOG_NOTICE);
}
else {
if (!variable_get('mailchimp_test_mode')) {
watchdog('mailchimp', 'A problem occurred subscribing @email to list @list.', array(
'@email' => $email,
'@list' => $list_id,
), WATCHDOG_WARNING);
}
}
} catch (Exception $e) {
watchdog('mailchimp', 'An error occurred subscribing @email to list @list. "%message"', array(
'@email' => $email,
'@list' => $list_id,
'%message' => $e
->getMessage(),
), WATCHDOG_ERROR);
}
return $result;
}