hugofirth / laravel-mailchimp

A composer package for the MailChimp API PHP class (as provided by MailChimp) which supports the Laravel 4 framework.
96 stars 27 forks source link

How to disable double opt-in? #30

Open simplenotezy opened 9 years ago

simplenotezy commented 9 years ago

I have tried this:

  MailchimpWrapper::lists()->subscribe('some_id', array('email'=>'some@email.dk'), array('double_optin'      => false));
mbsmi commented 9 years ago

I am needing to find out the same for disabling double opt in and to update an existing email address.

The code that I have attempted to use is:

MailchimpWrapper::lists()->subscribe('list_id', array('email' => Input::get('email'), array('FNAME' => Input::get('first_name'), 'LNAME' => Input::get('last_name')), 'double_optin' => false, 'update_existing' => true));
bartmoons commented 9 years ago

This works for me:

MailchimpWrapper::lists()->subscribe($list_id, array('email' => $input['email']), null, null, false, true);

null is first name and last name

hoshomoh commented 9 years ago

Thanks @bartmoons will try this out and see if it will also work for me.

zeckdude commented 8 years ago

I was looking for a solution where I can write the option names as keys for a multidimensional array like so:

MailchimpWrapper::lists()
    ->subscribe($list_id,
      array(
        'email' => $email_address,
      ),
      array(
        'merge_vars' => array('FNAME' => $first_name, 'LNAME' => $last_name),
        'double_optin' => false,
        'update_existing' => true,
        'replace_interests' => false,
        'send_welcome' => false
      )
);

But unfortunately I couldn't figure out the syntax for that (if it is even possible), so thanks for @bartmoons' suggestion, I was able to get it work like so:

MailchimpWrapper::lists()
    ->subscribe($list_id,
      array(
        'email' => $email_address,
      ),
      array('FNAME' => $first_name, 'LNAME' => $last_name),
      "html", // email type
      false, // double optin
      true, // update existing
      false, // replace interests
      false //send welcome
);

Using this approach you will need to add each parameter, at least until the one you want to specify, even though they're actually optional.