Affiliates
Hook Reference
| Hook | Description |
|---|---|
fluent_affiliate/admin_app_rendering | Fired just before the admin SPA is rendered. |
fluent-affiliate_loading_app | Fired while the admin SPA assets are enqueued, after the admin stylesheets and before the admin app script. |
fluent_affiliate/affiliate_updated | Fired after an affiliate record is updated by an admin. |
fluent_affiliate/before_delete_affiliate | Fires immediately before an affiliate is permanently deleted. |
fluent_affiliate/after_delete_affiliate | Fires after an affiliate has been permanently deleted. |
fluent_affiliate/affiliate_status_to_{status} | Fired when an affiliate's status changes. |
fluent_affiliate/affiliate_created | Fired after a new affiliate record is created. |
fluent_affiliate/admin_app_rendering
Fired just before the admin SPA is rendered. Useful for adding custom scripts or data.
Source: app/Hooks/Handlers/AdminMenuHandler.php
add_action('fluent_affiliate/admin_app_rendering', function() {
wp_enqueue_script('my-admin-extension', MY_PLUGIN_URL . 'admin-ext.js', ['jquery'], '1.0', true);
});fluent-affiliate_loading_app
Fired while the admin SPA assets are enqueued, after the admin stylesheets and before the admin app script. Use it to enqueue your own scripts or styles that extend the FluentAffiliate admin app. The fluent-affiliate prefix is the plugin slug from config/app.php.
Source: app/Hooks/Handlers/AdminMenuHandler.php
add_action('fluent-affiliate_loading_app', function() {
wp_enqueue_script('my-fa-addon', plugins_url('admin.js', __FILE__), [], '1.0.0', true);
});fluent_affiliate/affiliate_updated
Fired after an affiliate record is updated by an admin.
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliate | Affiliate | The updated Affiliate model. |
$by | string | Who triggered the update — "by_admin". |
$data | array | Array of changed data. |
Source: app/Http/Controllers/AffiliateController.php
add_action('fluent_affiliate/affiliate_updated', function($affiliate, $by, $data) {
// Log the change or notify an external system.
}, 10, 3);fluent_affiliate/before_delete_affiliate
Fires immediately before an affiliate is permanently deleted.
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliate | Affiliate | The affiliate about to be deleted. |
Source: app/Http/Controllers/AffiliateController.php
add_action('fluent_affiliate/before_delete_affiliate', function($affiliate) {
error_log('Deleting affiliate #' . $affiliate->id);
});fluent_affiliate/after_delete_affiliate
Fires after an affiliate has been permanently deleted.
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliateId | int | The ID of the deleted affiliate. |
Source: app/Http/Controllers/AffiliateController.php
add_action('fluent_affiliate/after_delete_affiliate', function($affiliateId) {
// Clean up related custom data.
});fluent_affiliate/affiliate_status_to_{status}
Fired when an affiliate's status changes. The hook name is dynamic: the suffix is the new status (e.g. active, inactive, banned).
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliate | Affiliate | The Affiliate model with its new status. |
$prevStatus | string | The previous status, or an empty string on first activation. |
Source: app/Http/Controllers/AffiliateController.php
// Fires for any status change
add_action('fluent_affiliate/affiliate_status_to_active', function($affiliate, $prevStatus) {
// e.g. send a "you're approved" email
}, 10, 2);fluent_affiliate/affiliate_created
Fired after a new affiliate record is created.
Parameters
| Parameter | Type | Description |
|---|---|---|
$affiliate | Affiliate | The newly created Affiliate model instance. |
$user | User | The WordPress User model associated with the affiliate. |
Source: app/Models/User.php
add_action('fluent_affiliate/affiliate_created', function($affiliate, $user) {
// Send a welcome email, sync to CRM, etc.
my_plugin_send_affiliate_welcome($affiliate->payment_email);
}, 10, 2);