Skip to content

unsubscribe ​

php
boolean  unsubscribe ( number $newStatus, number $shipmentId )

Unsubscribes the currently processed address and updates its status for the specified mailing to “unsubscribed” or “wants to unsubscribe”.

Warning

Requires an address context.

Parameters

In $newStatus, specify the new status to assign to the address in the database:

  • 3 - unsubscribed.
  • 4 - wants to unsubscribe.

In $shipmentId, specify the mailing ID whose status should be updated.

Return values

Returns the boolean value true if the status was updated successfully. Returns false when:

  • The current address status in the database is less than or equal to 4.
  • The supplied $newStatus value is invalid.

Example

php

$newStatus = 3;
$shipmentId = 1234;

if (unsubscribe($newStatus, $shipmentId)) {
    print("The address was unsubscribed successfully.");
} else {
    print("Failed to change the status (the address was probably already unsubscribed).");
}

Result

The address was unsubscribed successfully.