Hooks & filters
WooFraudGuard exposes a wide surface of WordPress hooks for customisation. Listed below in the order they fire during a typical evaluation.
Actions
woofraudguard_register_rules ( RuleRegistry $registry )— fires once on plugin bootstrap. Register your own rules here.woofraudguard_before_evaluate ( OrderContext $ctx, WC_Order $order )— fires just before rule evaluation. Use to enrich the context.woofraudguard_after_evaluate ( ScoreReport $report, WC_Order $order )— fires after evaluation, before any action is dispatched. Use to integrate with external systems (Slack alerts, Sentry breadcrumbs, etc.).woofraudguard_decision_dispatched ( Decision $decision, ScoreReport $report, WC_Order $order )— fires after the order has been approved, held, or cancelled.woofraudguard_chargeback_recorded ( int $order_id, array $payload )— fires when a chargeback webhook arrives and is verified.
Filters
woofraudguard_settings ( array $settings )— wraps every settings read. Use to lock weights/thresholds.woofraudguard_order_context ( OrderContext $ctx, WC_Order $order )— modify the context before rule evaluation.woofraudguard_rule_weight ( float $weight, string $rule_key, array $settings )— adjust a specific rule\’s weight at evaluation time.woofraudguard_customer_message ( string $message, string $decision_key )— customize the checkout refusal message.woofraudguard_velocity_window_minutes ( int $minutes )— adjust the velocity-rule lookback window.woofraudguard_datacenter_cidrs ( array $cidrs )— extend the bundled datacenter CIDR list.woofraudguard_disposable_domains ( array $domains )— extend the bundled disposable-email-domain list at runtime.woofraudguard_pricing_url ( string $url )— change the URL the upsell cards link to.woofraudguard_openai_model ( string $model )— override the OpenAI model name.woofraudguard_groq_model ( string $model )— override the Groq model name.
Example: integrating with Slack
add_action( \'woofraudguard_after_evaluate\', function ( $report, $order ) {
if ( $report->decision->value === \'cancel\' ) {
wp_remote_post( \'https://hooks.slack.com/services/...\', [
\'body\' => json_encode( [
\'text\' => sprintf( \':warning: WFG cancelled order #%d (score %d)\',
$order->get_id(), (int) $report->totalScore ),
] ),
] );
}
}, 10, 2 );