website logo
Thrive Themes
Navigate through spaces
Thrive Themes
⌘K
General
⚙️Thrive Themes Action Hooks & Custom Functions
⚙️How Can You Extend Thrive Themes Capabilities as a Developer
⚙️How to Integrate Your Thrive Themes Site to a Third Party Autoresponder
Thrive Architect
⚙️How to Develop Custom Rules For the Conditional Display Option
Thrive Automator
Untitled doc
⚙️Thrive Automator for Developers - Extending Automations' Capabilities
⚙️What Type of Data Do Thrive Automator Triggers and Actions Use?
⚙️Creating a New Start Trigger
⚙️Creating a New Filter in Thrive Automator
⚙️Creating a New Action in Thrive Automator
⚙️Creating Data Fields
⚙️Creating Trigger Fields
⚙️Creating Action Fields
⚙️Creating Apps
⚙️Creating Data Objects
Docs powered by archbee 
10min

Creating a New Filter in Thrive Automator

About filters

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.

Creating your first filter

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.
PHP
|
<?php
public static function get_id(): string {
		return 'wp/user-filter';
	}

  • abstract public static function get_name(): string - should return a string containing the name of the filter.
PHP
|
<?php
	public static function get_name(): string {
		return 'User 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.
PHP
|
<?php
public static function get_operators(): array {
		return [
			'new'  => [
				'label' => 'is fresh user',
			],
			'old'  => [
				'label' => 'is old user',
			],
		];
	}




  • 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.
PHP
|
<?php
public static function filter( $data ): bool {
	    //verifications and validations
		return true;
	}


Other methods

  • 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.
PHP
|
<?php
	public static function prepare_data( $data ) {
        if ( isset( $data['value'] ) ) {
			$this->value = $data['value'];
		}
	}


Registering the filter

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?
Yes
No
UP NEXT
Creating a New Action in Thrive Automator
Docs powered by archbee 
TABLE OF CONTENTS
About filters
Creating your first filter
Other methods
Registering the filter