You are here

public function CampaignMonitor::createList in Campaign Monitor 7

Create a new list at the Campaign Monitor servers.

The side-effect is that the local cache is cleared.

Parameters

string $title: The title of the new list.

string $unsubscribe_page: An optional page to redirect subscribers to when they unsubscribe.

bool $confirmed_opt_in: Whether or not this list requires to confirm the subscription. Defaults to FALSE.

string $success_page: An optional page to redirect subscribers to when they confirm their subscription.

Return value

bool TRUE on success, FALSE otherwise.

File

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

Class

CampaignMonitor
Implementation of the CampaignMonitor class.

Code

public function createList($title, $unsubscribe_page = '', $confirmed_opt_in = FALSE, $success_page = '') {
  if ($obj = $this
    ->createListObj(NULL)) {
    $result = $obj
      ->create($this->clientId, [
      'Title' => check_plain($title),
      'UnsubscribePage' => check_plain($unsubscribe_page),
      'ConfirmedOptIn' => $confirmed_opt_in,
      'ConfirmationSuccessPage' => check_plain($success_page),
    ]);
    if ($result
      ->was_successful()) {

      // Clear the cache, so the list information can be retrieved again.
      $this
        ->clearCache();
      return TRUE;
    }
    else {
      $this
        ->addError(WATCHDOG_ERROR, $result->response->Message, $result->http_status_code);
      return FALSE;
    }
  }
  return FALSE;
}