You are here

function CMBase::subscriberAddRedundant in Campaign Monitor 5.2

* This encapsulates the check of whether this particular user unsubscribed once. *

Parameters

string $email Email address.: * @param string $name User's name. * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used.

File

lib/CMBase.php, line 410

Class

CMBase

Code

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;
}