Affiliates
Hook Reference
| Hook | Description |
|---|---|
fluent_affiliate/affiliate_by_param | Filters the resolved Affiliate model when looking up an affiliate from a URL parameter. |
fluent_affiliate/affiliate_widgets | Filters the widgets displayed on the affiliate single-view page. |
fluent_affiliate/affiliate_view_data | Filters the affiliate model returned by the single-affiliate admin endpoint (GET /affiliates/{id}), after attached coupons and the share URL have been set. |
fluent_affiliate/affiliate_customers_query | Filters the customer query for an affiliate before pagination. |
fluent_affiliate/affiliate_customers_response | Filters the customers response payload for an affiliate. |
fluent_affiliate/affiliate_attached_coupons | Filters the coupons attached to an affiliate. |
fluent_affiliate/affiliate_avatar | Filters the avatar URL used for an affiliate or customer record. |
fluent_affiliate/checkout_affiliate | Filters the affiliate resolved at checkout for an order. |
fluent_affiliate/affiliate_by_param
Filters the resolved Affiliate model when looking up an affiliate from a URL parameter.
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliate | `Affiliate | null` |
$paramId | string | The tracking parameter value from the URL. |
Source: app/Helper/Utility.php
add_filter('fluent_affiliate/affiliate_by_param', function($affiliate, $paramId) {
// Fall back to lookup by email
if (!$affiliate) {
return Affiliate::where('payment_email', $paramId)->first();
}
return $affiliate;
}, 10, 2);fluent_affiliate/affiliate_widgets
Filters the widgets displayed on the affiliate single-view page.
Parameters
| Parameter | Type | Description |
|---|---|---|
$widgets | array | Existing widget definitions. |
$affiliate | Affiliate | The affiliate being viewed. |
Source: app/Http/Controllers/AffiliateController.php
add_filter('fluent_affiliate/affiliate_widgets', function($widgets, $affiliate) {
$widgets[] = ['type' => 'custom_metric', 'title' => 'Custom KPI', 'value' => 42];
return $widgets;
}, 10, 2);fluent_affiliate/affiliate_view_data
Filters the affiliate model returned by the single-affiliate admin endpoint (GET /affiliates/{id}), after attached coupons and the share URL have been set. Pro uses this to append custom registration field values.
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliate | Affiliate | The Affiliate model being returned to the admin SPA. |
Source: app/Http/Controllers/AffiliateController.php
add_filter('fluent_affiliate/affiliate_view_data', function($affiliate) {
$affiliate->my_extra_data = get_user_meta($affiliate->user_id, 'my_field', true);
return $affiliate;
});fluent_affiliate/affiliate_customers_query
Filters the customer query for an affiliate before pagination. Pro uses this to narrow results by lifetime status (active/expired).
Parameters
| Parameter | Type | Description |
|---|---|---|
$query | Builder | The customers query, scoped to the affiliate. |
$request | Request | The current request. |
$affiliateId | int | The affiliate ID. |
Source: app/Http/Controllers/AffiliateController.php
add_filter('fluent_affiliate/affiliate_customers_query', function($query, $request, $affiliateId) {
return $query->where('status', 'active');
}, 10, 3);fluent_affiliate/affiliate_customers_response
Filters the customers response payload for an affiliate. Pro appends group-aware lifetime_expiry_days for the expiry display.
Parameters
| Parameter | Type | Description |
|---|---|---|
$response | array | Response payload (contains the paginated customers). |
$affiliate | Affiliate | The affiliate being viewed. |
$request | Request | The current request. |
Source: app/Http/Controllers/AffiliateController.php
add_filter('fluent_affiliate/affiliate_customers_response', function($response, $affiliate, $request) {
$response['meta'] = ['lifetime' => true];
return $response;
}, 10, 3);fluent_affiliate/affiliate_attached_coupons
Filters the coupons attached to an affiliate.
Parameters
| Parameter | Type | Description |
|---|---|---|
$coupons | array | Array of coupon definitions. |
$affiliate | Affiliate | The affiliate. |
$context | string | Context string (e.g. "portal", "admin"). |
Source: app/Models/Affiliate.php
add_filter('fluent_affiliate/affiliate_attached_coupons', function($coupons, $affiliate, $context) {
$coupons[] = ['code' => 'AFF' . strtoupper($affiliate->custom_param), 'discount' => '10%'];
return $coupons;
}, 10, 3);fluent_affiliate/affiliate_avatar
Filters the avatar URL used for an affiliate or customer record. Defaults to a Gravatar URL built from the email hash — return your own URL to use a different avatar source.
Parameters
| Parameter | Type | Description |
|---|---|---|
$url | string | The default Gravatar URL (128px). |
$email | string | Email address the avatar is resolved for. |
Source: app/Models/Customer.php
add_filter('fluent_affiliate/affiliate_avatar', function($url, $email) {
$userId = email_exists($email);
$custom = $userId ? get_user_meta($userId, 'my_avatar_url', true) : '';
return $custom ?: $url;
}, 10, 2);fluent_affiliate/checkout_affiliate
Filters the affiliate resolved at checkout for an order. Pro's lifetime commission feature uses this to attribute an order to the affiliate who originally referred the customer.
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliate | `Affiliate | null` |
$customerData | array | Customer data for the order (email, name, etc.). |
$provider | string | The integration provider key (e.g. woo, edd). |
Source: app/Modules/Integrations/BaseConnector.php
add_filter('fluent_affiliate/checkout_affiliate', function($affiliate, $customerData, $provider) {
return $affiliate;
}, 10, 3);