You are here

public function CampaignMonitorManager::updateSubscriberEmail in Campaign Monitor 8.2

Updates the subscriber e-mail address for a given list.

Parameters

array $listId: The unique Campaign Monitor list ID.

string $oldEmail: The old e-mail address.

string $email: The new e-mail address.

File

src/CampaignMonitorManager.php, line 1054

Class

CampaignMonitorManager
Manager for Campaignmonitor.

Namespace

Drupal\campaignmonitor

Code

public function updateSubscriberEmail(array $listId, $oldEmail, $email) {
  if ($obj = $this
    ->createSubscriberObj($listId)) {
    $result = $obj
      ->update($oldEmail, [
      'EmailAddress' => $email,
      'Resubscribe' => TRUE,
    ]);
    if (!$result
      ->was_successful()) {
      $this
        ->addError($result->response->Message, $result->http_status_code);
      return FALSE;
    }

    // Remove the old e-mail address from the subscriber cache.
    $this
      ->removeSubscriberFromCache($listId, $oldEmail);
    return TRUE;
  }
}