Thrive Automator
Creating a New Filter in Thrive Automator
7min
A Trigger will be executed at all times, but there are cases in which we might not want to run the action. The main purpose of a Filter is to decide whether we want to run an action or not, based on the data we have.
In order to create your own Filter you need to extend Thrive\Automator\Items\Filter 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.
- abstract public static function get_name(): string - should return a string containing the name of the filter.
- abstract public static function get_operators(): array - returns an array of operators that will be used in the admin UI when setting the automation.
- abstract public static function filter( $data ): bool - this method receives as parameter an array of $data from the Data_Field value and should return true or false.
- abstract public static function prepare_data( $data ) - receives the data that was set when creating the automation and saves it on the instance so it can be compared later.
In order to register a Filter so it can be used inside an automation, we should use the thrive_automator_register_filter function which receives as the only parameter, the class name.
Updated 03 Mar 2023

Did this page help you?