Bug in PHP API

function subscriberAddRedundant( $email, $name, $list_id = null )
{
    $added = $this->subscriberAdd( $email, $name, $list_id );
            
    if ( $added && $added['Code'] == '0' )
    {
        $subscribed = $this->subscribersGetIsSubscribed( $email, $list_id );
        // Must have unsubscribed, so resubscribe
        if ( $subscribed == 'False' )
        {
            // since we're internal, we'll just call the method with full parameters rather
            // than go through a secondary wrapper function.
            $added = $this->subscriberAdd( $email, $name, $list_id, true );
            return $added;
        }
    }
    
    return $added;
}

should be:

function subscriberAddRedundant( $email, $name, $list_id = null )
{
    $added = $this->subscriberAdd( $email, $name, $list_id );        
        
    if ( $added && $added['Result']['Code'] == '204' )
    {
        $subscribed = $this->subscribersGetIsSubscribed( $email, $list_id );    
    
        // Must have unsubscribed, so resubscribe
        if ( $subscribed['anyType'] == 'False' )
        {
            // since we're internal, we'll just call the method with full parameters rather
            // than go through a secondary wrapper function.
            $added = $this->subscriberAdd( $email, $name, $list_id, true );
            return $added;
        }
    }
        
    return $added;
}
Ben Ben, 7 years ago

Thank you very much for posting this bug, we've updated the sample with your fix.

Join 150,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098