1. Home
  2. Knowledge Base
  3. Developer Documentation
  4. Creating Thrive Automator Data Fields

Creating Thrive Automator Data Fields

Important Note: As we continue to grow and expand our product suite at Thrive Themes, we’ve made the strategic decision to retire Thrive Automator and partner up with our sister brand, Uncanny Automator that offers over 195+ integrations, 1000+ triggers and actions, and much more.

Learn more about what this means for you and for Thrive Automator.


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.

Creating Your First Data_Field

To create your own Data_Field you need to extend ThriveAutomatorItemsData_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

public static function get_id(): string { 
    return 'wp/username'; 
}
  • abstract public static function get_name(): string – the name of the field that will be displayed in the admin UI when creating a filter

public static function get_name(): string { 
    return 'Username'; 
}
  • abstract public static function get_description(): string – a short description for the field to help users understand what it represents

public static function get_description(): string {  
    return 'The username used by the user to login'; 
}
  • abstract public static function get_placeholder(): string – placeholder to be used for inputs in the admin UI

public static function get_placeholder(): string { 
    return 'username'; 
}
  • 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.

public static function get_supported_filters(): array { 
    return [ 'string_contains', 'string_equals', 'dropdown' ]; 
}

Other Methods

  • 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.

public static function is_ajax_field(): bool { 
    return true; 
}
  • 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.

public static function get_field_value_type(): string { 
    return true; 
}
  • 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.

public static function get_options_callback(): array { 
   return return [ 
             [ 
                 'id' => 1, 'label' => 'Label 1', 
             ], 
          ]; 
}
  • public static function primary_key(): array – 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

    public static function primary_key(): array { 
    return [ User_Data::get_id() ];
    }

Registering the Data Field

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.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support
>