applyFilters( "area_trigger_conditions", conditions, area );
applyFilters( "area_trigger_conditions_{key}", conditions, area );
Filter the condition promise before a trigger is fired. This filter is called every time an automatic trigger is fired.
The dynamic part of the filter name is the sanitized Area key. See DiviAreaItem.theKey()
for details.
When all conditions are met, the Area is opened. When one condition fails, the Area stays hidden.
Params
conditions
- A promise that resolve()s when all conditions are met, or reject()s when a condition is not met.
area
- The new area instance.
Returns
This filter must return a Promise!
Examples
addAction("area_trigger_conditions", function(conditions, area) {
function customCheck(resolve, reject) {
if (DiviArea.isClosed(area)) {
reject("Area is still marked as closed");
} else {
resolve();
}
}
conditions = conditions.then(() => new Promise(customCheck));
return conditions;
});
Notes
As the Area is only displayed after the Promise was resolved, you should avoid to use time consuming checks (such as Ajax requests) during this filter. If a condition takes a longer to validate, it’s better to check it during the area_general_conditions
filter, which runs directly after the page has loaded.