Greg Greg - 2 years ago 147
PHP Question

Mailchimp double_optin option not working

I've followed this tutorial to implement mailchimp API v2.0 on my website.
It works great, however the double_optin option that I wanted to add and set to false (so that users don't need to validate their registration via e-mail) doesn't seem to be working. It's like if it was not taken into consideration at all, users still need to validate the registration via e-mail.


'double_optin' => false
placed at the wrong place? I had a look at mailchimp documentation but my level in programmation is not good enough to identify what is wrong.
Thanks for your help

$api_key = "12345486-us8";

$list_id = "123";

$Mailchimp = new Mailchimp( $api_key );
$Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp );
$subscriber = $Mailchimp_Lists->subscribe( $list_id, array( 'email' => htmlentities($_POST['email']),'double_optin' => false ) );

if ( ! empty( $subscriber['leid'] ) ) {
echo "success";
echo "fail";


Answer Source

According to this (admittedly unofficial-looking) Mailchip_Lists documentation, you'll want to pass FALSE as the 5th parameter to subscribe().


$double_optin = FALSE;

$subscriber = $Mailchimp_Lists->subscribe(
    array('email' => htmlentities($_POST['email'])),
    NULL, // merge_vars
    'html', // email_type
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download