You are here

function mailchimp_subscribe in Mailchimp 8

Same name and namespace in other branches
  1. 7.5 mailchimp.module \mailchimp_subscribe()
  2. 7.3 mailchimp.module \mailchimp_subscribe()
  3. 7.4 mailchimp.module \mailchimp_subscribe()
  4. 2.x mailchimp.module \mailchimp_subscribe()

Subscribe a user to a Mailchimp list in real time or by adding to the queue.

See also

Mailchimp_Lists::subscribe()

3 calls to mailchimp_subscribe()
MailchimpListsSubscriptionTest::testSubscribe in modules/mailchimp_lists/src/Tests/MailchimpListsSubscriptionTest.php
Tests subscribing a member to a list.
MailchimpSignupPageForm::submitForm in modules/mailchimp_signup/src/Form/MailchimpSignupPageForm.php
Form submission handler.
mailchimp_lists_process_subscribe_form_choices in modules/mailchimp_lists/mailchimp_lists.module
Processor for various list form submissions.

File

./mailchimp.module, line 424
Mailchimp module.

Code

function mailchimp_subscribe($list_id, $email, $merge_vars = NULL, $interests = [], $double_optin = FALSE, $format = 'html', $language = NULL, $gdpr_consent = FALSE) {
  $config = \Drupal::config('mailchimp.settings');
  if (empty($language)) {
    $language = \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getId();
  }
  if ($config
    ->get('cron')) {
    $args = [
      'list_id' => $list_id,
      'email' => $email,
      'merge_vars' => $merge_vars,
      'interests' => $interests,
      'double_optin' => $double_optin,
      'format' => $format,
      'language' => $language,
      'gdpr_consent' => $gdpr_consent,
    ];
    return mailchimp_addto_queue('mailchimp_subscribe_process', $args);
  }
  return mailchimp_subscribe_process($list_id, $email, $merge_vars, $interests, $double_optin, $format, $language, $gdpr_consent);
}