You are here

public function CampaignMonitor::updateSubscriberEmail in Campaign Monitor 7

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

Parameters

string $list_id: The unique Campaign Monitor list ID.

string $old_email: The old e-mail address.

string $email: The new e-mail address.

Return value

bool TRUE on success, FALSE otherwise.

File

lib/campaignmonitor.class.inc, line 988
Implementation of the CampaignMonitor class.

Class

CampaignMonitor
Implementation of the CampaignMonitor class.

Code

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

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