Thrive Automator
Creating Data Fields
15min
Data fields represent the data that is stored in a Data_Object and are mostly used for filtering inside an automation.
For example, you might run a login trigger, but you want to execute an action, just for a specific user role, ID, or last login date.
To create your own Data_Field you need to extend Thrive\Automator\Items\Data_Field and implement the required basic methods.
- abstract public static function get_id(): string - should return a unique identifier that will be used together with the Data_Object. To avoid conflicts or overwrites we suggest using a prefix
PHP
|
- abstract public static function get_name(): string - the name of the field that will be displayed in the admin UI when creating a filter
PHP
|
- abstract public static function get_description(): string - a short description for the field to help users understand what it represents
PHP
|
- abstract public static function get_placeholder(): string - placeholder to be used for inputs in the admin UI
PHP
|
- abstract public static function get_supported_filters(): array - return an array of filters that are supported by our field. Some filters are already implemented by Thrive Automator plugin (check inc/classes/items/filters), but more can be added.
PHP
|
- abstract public static function is_ajax_field(): bool - determine if the values used for filtering in admin UI are returned directly or through an ajax request. By default, this method returns false.
PHP
|
- abstract public static function get_field_value_type(): string - return field value's type. Based on this we determine whether the field can be used as dynamic data.
PHP
|
- abstract public static function get_options_callback(): array - return an array of ID/label arrays that will be used to display values in filters. In case is_ajax_field() method returns true, values for filter compare will be retrieved with an ajax request. Ajax options values are usually used for select dropdowns.
PHP
|
- - return an array of Data_Objects ids of those data objects that can be initialized by this field value. Those are used for Webhook and Advanced Data Mapping items where you can map a text/number to a dataset
PHP
|
To register a Data_Field so it can be used by data objects and filters, we should use the thrive_automator_register_data_field function which receives as the only parameter, the class name.

Updated 03 Mar 2023
Did this page help you?