Files
piratepoet/doc/api_methods/UpdateSubscriber.md
Pavel Dohnal 2cdb12f712 Add Update Subscrber method to MP API
[MAILPOET-6168]
2024-07-25 15:10:57 +02:00

32 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[back to list](../Readme.md)
# Update Subscriber
## `array updateSubscriber($subscriberIdOrEmail, array $subscriber): array`
This method allows a subscriber to be updated.
The argument `$subscriber` is similar to [Add Subscriber](AddSubscriber.md) method, but the subscriber is updated instead of created.
It returns the updated subscriber. See [Get Subscriber](GetSubscriber.md) for a subscriber data structure.
## Arguments
| Argument | Type | Description |
| -------------------- | ------------- | ----------------------------------------- |
| $subscriberIdOrEmail | string or int | An id or email of an existing subscriber. |
| $subscriber | array | Subscriber data that will be updated |
## Error handling
All expected errors from the API are exceptions of class `\MailPoet\API\MP\v1\APIException`.
Code of the exception is populated to distinguish between different errors.
An exception of base class `\Exception` can be thrown when something unexpected happens.
Codes description:
| Code | Description |
| ---- | -------------------------------------------------- |
| 4 | Updating a subscriber that does not exist. |
| 13 | The subscriber couldnt be updated in the database |