Add documentationfor adding custom fields api

[MAILPOET-2041]
This commit is contained in:
Pavel Dohnal
2019-05-30 10:14:19 +02:00
committed by M. Shull
parent c15c693507
commit 5df3c6c46e
3 changed files with 67 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ Class `\MailPoet\API\API` becomes available once MailPoet plugin is loaded by Wo
### Available API Methods ### Available API Methods
* [Add List (addList)](api_methods/AddList.md) * [Add List (addList)](api_methods/AddList.md)
* [Add Subscriber (addSubscriber)](api_methods/AddSubscriber.md) * [Add Subscriber (addSubscriber)](api_methods/AddSubscriber.md)
* [Add Subscriber Field(addSubscriberField)](api_methods/AddSubscriberField.md)
* [Get Lists (getLists)](api_methods/GetLists.md) * [Get Lists (getLists)](api_methods/GetLists.md)
* [Get Subscriber (getSubscriber)](api_methods/GetSubscriber.md) * [Get Subscriber (getSubscriber)](api_methods/GetSubscriber.md)
* [Get Subscriber Fields (getSubscriberFields)](api_methods/GetSubscriberFields.md) * [Get Subscriber Fields (getSubscriberFields)](api_methods/GetSubscriberFields.md)

View File

@@ -0,0 +1,65 @@
[back to list](../Readme.md)
# Add Subscriber Field
## `array addSubscriberField(array $data)`
Using this method you can create custom properties that can be used for storing additional data for each subscriber.
See [Subscriber Fields for more details](./GetSubscriberFields.md)
## Arguments
### `$data` (required)
| Property | Type | Limits | Description |
| --- | --- | --- | --- |
| name (required) | string | 90 chars | Human readable name. Intended to be used, as an example, as a label for form input. |
| type (required) | string | - | Type of the field. Possible values are: `text`, `date`, `textarea`, `radio`, `checkbox`, `select` |
| params (optional) | array | - | Contains various information, see examples below. |
### `$params`
Params array differs for each type.
The common properties for all types:
| Property | Type | Description |
| --- | --- | --- |
| required | string | Indicates if the value must be provided for each subscriber. Possible values are: "1" or "" |
| label | string | Label used for displaying the field to the end user. |
#### `$params` for text, textarea types
| Property | Type | Description |
| --- | --- | --- |
| validate | string | Can be used for validating input values. Possible values are: `number`, `alphanum`, `phone` |
#### `$params` for checkbox types
| Property | Type | Description |
| --- | --- | --- |
| values | array | Same array as for radio type. Must contain exactly 1 element |
#### `$params` for radio, select types
| Property | Type | Description |
| --- | --- | --- |
| values | array | Contains a list of options. Each element must contain a string `value` and can contain `is_checked` |
#### `$params` for date type
| Property | Type | Description |
| --- | --- | --- |
| date_type | string | Possible values are: Values: `year_month_day`, `year_month`, `month`, `day` |
| date_format | string | Values: for year_month_day: 'MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD', for year_month: 'YYYY/MM', 'MM/YY', for year: 'YYYY', for month: 'MM' |
## Response
| Property | Type | Limits | Description |
| --- | --- | --- | --- |
| id | string | 11 chars |Field Id |
| name | string | 90 chars | Human readable name. Intended to be used, as an example, as a label for form input. |
| type | string | - | Type of the field. Possible values are: `text`, `date`, `textarea`, `radio`, `checkbox`, `select` |
| params | array | - | Contains various information, see examples below. |
| created_at | string\|null | - | UTC time of creation in 'Y-m-d H:i:s' format |
| updated_at | string | - | UTC time of last update in 'Y-m-d H:i:s' format |

View File

@@ -7,6 +7,7 @@
Each subscriber has a set of default properties (`email`, `first_name`, `last_name`). Each subscriber has a set of default properties (`email`, `first_name`, `last_name`).
MailPoet enables the extension of these properties by adding custom properties. MailPoet enables the extension of these properties by adding custom properties.
This method returns list of all properties available for a subscriber (default + custom). This method returns list of all properties available for a subscriber (default + custom).
See also [addSubscriberField function](./AddSubscriberField.md)
## Subscriber Field ## Subscriber Field