1. Support
  2. /
  3. Developer Documentation
  4. /
  5. Custom User Persona Rules

Custom User Persona Rules

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

How can we help?