1. Support
  2. /
  3. Documentation
  4. /
  5. Developer Documentation
  6. /
  7. Available Hooks

Available Hooks

dxp_toolkit_allow_cache

Need to disable or control session-based rule caching? The dxp_toolkit_allow_cache filter controls if a rule's value will be cached for subsequent checks in the same user session.

Parameters

This filter accepts one boolean parameter, the default value for allowing session caching.

Return value

This filter must return a value of type boolean, true if session caching is allowed or false otherwise.
By default, this filter returns true.

Additional Usage

Session caching can also be configured by defining a constant named DXPTK_ALLOW_CACHE. If set to false, session caching will not be used.
This constant defaults to the inverse of the WP_DEBUG constant if it is defined, or true otherwise.

dxp_toolkit_gdpr_allow_cookie

Need to disable or control cookie usage? The dxp_toolkit_gdpr_allow_cookie filter controls if a cookie is set during a page visit. One way to comply with GDPR and similar requirements might be to use explicit consent, acknowledging and authorizing the DXP ToolKit cookie prior to it being set.

Parameters

This filter accepts one boolean parameter, the default value for allowing cookies.

Return value

This filter must return a value of type boolean, true if cookies are allowed or false otherwise.
By default, this filter returns true.

Usage example


add_filter('dxp_toolkit_gdpr_allow_cookie', 'myFunction');
function myFunction($allowCookies)
{
if (userGaveConsent()) { //Add your custom GDPR validation here
return true;
}
return false;
}

dxp_toolkit_ruleset

Need to add custom persona rules to DXP ToolKit? The dxp_toolkit_ruleset filter enables developers to add their own persona rules to the ruleset.
These custom persona rules need to have their own custom validation logic implemented in order to work.
The validation logic must return a boolean value, as seen in the next example.

Parameters

This filter accepts one array parameter, the existing custom DXP ToolKit ruleset.

Return value

This filter must return a value of type array, with the same structure as seen in the example below.

Usage example


add_filter('dxp_toolkit_ruleset', 'myCustomRule');
/**
* Custom persona rule declaration.
* @param array $customRuleset An array of registered custom persona rules.
* @return array $customRuleset The modified custom persona ruleset.
*/
function myCustomRule($customRuleset)
{
/**
* Required Array Structure
*
* array key REQUIRED. Unique slug for your custom persona rule.
* array value REQUIRED. Your custom persona rule title.
*/
$customRuleset['my_custom_rule'] = 'My Custom Persona Rule';
return $customRuleset;
}

dxp_toolkit_custom_condition_{$rule_type}

This action is fired for your specific custom persona rule, defined in the dxp_toolkit_ruleset filter.

Return value

This filter must return a value of type boolean, indicating if the persona rule is evaluated to true or false.

Usage example


add_action(‘dxp_toolkit_custom_condition_my_custom_rule’, ‘myRuleValidator’);
/**
* Custom persona rule validator.
* @param array $data Custom data saved for the persona rule. Array keys are defined in the myCustomRule function.
* @return bool true if the rule is triggered, false otherwise
*/
function myRuleValidator()
{
return true; // The custom persona rule is triggered if the validator returns true.
}

Was this article helpful to you? Yes No