Adding filters to your triggers and actions
Add a filter to any trigger or action is as simple as click on the Add filter button:
Of course, you are able to configure unlimited filters for each trigger or action!
How filters works
Filters works as an extra condition for your triggers and actions and the way it works is different for each of them.
- On triggers, the automation execution will get stopped for users that does not meets the filters configured, since they will not be able to complete all the triggers of the automation and actions will not get executed.
- On actions, filters will limit the actions execution and executing only the actions that user meets the conditions from the filters configured.
Lets to check this with an example:
On the triggers area, we have trigger to meet when a user submits a Gravity Forms form. We have added a filter to only handle trigger to users that their meta “my_meta” has a value equal to “yes”.
Users without this meta or with a different meta value will not be able to get the actions executed (in this case, to get added to a WooCommerce coupon).
On the actions area, we have an action to add the user to a WooCommerce coupon. This action is limited to only users that their email contains the word “gmail” and ends with “com”.
Users that submits the form, but their email does not matches with those 2 conditions will not get added to the coupon.
Filters can work as a router for actions to let you decide to which users execute each action. There is an example of how it works:
This example shows how to add users to different coupons based on their role. The ways this automation will end for different users are:
- Users with Customer role: Will get added to “coupon 1”.
- Users with Contributor role: Will get added to “coupon 2”.
- Users with other roles: Will not get added to any coupon.
AND and OR operators
Operators decides how filters work together. The operator can be changed by clicking on the AND option:
The operator only have 2 possible values, AND and OR, and they are used to decide how restrictive a filter is.
- AND will make the filter more restrictive since will force that the filter condition need to fulfilled.
- OR will make the filter less restrictive since only requires that only 1 of the filters configured with the OR operator need to fulfilled.
Understanding operators with a real world example
Imagine that you ask a kid to give you a red pencil and a blue pencil. The unique correct solution is if the kid gives you the 2 pencils, since you have asked for both with the AND word.
If you ask the kid to give you a red pencil or a blue pencil, there are 3 correct solutions, if the kid gives you the red pencil, the blue pencil or both pencils since you asked for only one pencil of both with the OR word. The unique situation that solution will be incorrect for this case if is the kid gives you a pencil of a different color (greed, pink, etc).
Flat condition filter
The Flat condition is a powerful filter that lets you compare 2 values of your choice. It was designed mainly to allow you filter by tags values.
Here is an example using a flat condition to filter by a submitted field from Gravity Forms using the form field tag: