Hooks and Filters
The LicenceForge client library provides WordPress actions and filters that let you customise licence behaviour, respond to lifecycle events, and integrate with your plugin's own logic.
Note
These hooks are fired by the client library running on your customer's site. For server-side hooks on the LicenceForge installation itself, see Developer Hooks Reference.
Filters
wplf_client_api_args
Modify the arguments passed to wp_remote_post() and wp_remote_get() for all API requests made by the client library.
Signature
apply_filters( 'wplf_client_api_args', array $args )
| Parameter | Type | Description |
|---|---|---|
$args |
array | The arguments array for wp_remote_*. Includes timeout, headers, body, etc. |
Example: increase timeout and add a custom header
add_filter( 'wplf_client_api_args', function ( $args ) {
// Increase timeout for slow connections
$args['timeout'] = 30;
// Add a custom header for server-side logging
$args['headers']['X-My-Plugin-Version'] = '2.4.1';
return $args;
} );
wplf_client_is_valid
Override the result of a licence validation check. This filter runs after the server response has been received and parsed.
Signature
apply_filters( 'wplf_client_is_valid', bool $is_valid, array $response )
| Parameter | Type | Description |
|---|---|---|
$is_valid |
bool | Whether the licence was deemed valid based on the server response. |
$response |
array | The full parsed response from the validation endpoint. |
Example: force valid during local development
add_filter( 'wplf_client_is_valid', function ( $is_valid, $response ) {
// Bypass licence check on local development environments
if ( wp_get_environment_type() === 'local' ) {
return true;
}
return $is_valid;
}, 10, 2 );
Warning
Returning true from this filter bypasses all server-side validation. Use it only for development or tightly controlled scenarios. Never ship production code that unconditionally returns true.
wplf_client_cache_duration
Customise the transient cache TTL for licence validation results.
Signature
apply_filters( 'wplf_client_cache_duration', int $duration )
| Parameter | Type | Default | Description |
|---|---|---|---|
$duration |
int | 3600 (WPLF_Client) / 43200 (WPLF_Licensing) | Cache duration in seconds. |
Example: shorten cache for staging sites
add_filter( 'wplf_client_cache_duration', function ( $duration ) {
// Use a 5-minute cache on staging for faster feedback
if ( wp_get_environment_type() === 'staging' ) {
return 300;
}
return $duration;
} );
wplf_client_has_feature
Override the result of a feature availability check. This is useful for granting temporary access, beta testing, or multi-plugin bundle logic.
Signature
apply_filters( 'wplf_client_has_feature', bool $has_feature, string $feature_slug )
| Parameter | Type | Description |
|---|---|---|
$has_feature |
bool | The current result from the default feature check. |
$feature_slug |
string | The feature slug being checked (e.g. advanced-forms). |
Example: grant a feature to companion plugin users
add_filter( 'wplf_client_has_feature', function ( $has_feature, $feature_slug ) {
// Users who have the AcmeAddon plugin active get the
// 'advanced-forms' feature regardless of their tier.
if ( 'advanced-forms' === $feature_slug && is_plugin_active( 'acme-addon/acme-addon.php' ) ) {
return true;
}
return $has_feature;
}, 10, 2 );
Actions
wplf_client_activated
Fires immediately after a licence has been successfully activated for the current site.
Signature
do_action( 'wplf_client_activated', array $response )
| Parameter | Type | Description |
|---|---|---|
$response |
array | The full parsed response from the activation endpoint, including status, activation_count, activation_limit, and tier data. |
Example: log activation and flush rewrite rules
add_action( 'wplf_client_activated', function ( $response ) {
// Log the activation for internal analytics
error_log( sprintf(
'LicenceForge: Licence activated. Status: %s, Activations: %d/%d',
$response['status'],
$response['activation_count'],
$response['activation_limit']
) );
// Flush rewrite rules so licence-gated endpoints become available
flush_rewrite_rules();
} );
wplf_client_deactivated
Fires immediately after a licence has been deactivated for the current site.
Signature
do_action( 'wplf_client_deactivated', array $response )
| Parameter | Type | Description |
|---|---|---|
$response |
array | The full parsed response from the deactivation endpoint. |
Example: clean up on deactivation
add_action( 'wplf_client_deactivated', function ( $response ) {
// Remove scheduled cron events that depend on an active licence
wp_clear_scheduled_hook( 'acmeforms_daily_sync' );
// Flush rewrite rules to remove licence-gated endpoints
flush_rewrite_rules();
} );
wplf_client_license_invalid
Fires when a licence validation attempt returns a permanent error. This is triggered only for HTTP status codes 401, 403, or 404 -- not for temporary network failures or 5xx server errors.
Signature
do_action( 'wplf_client_license_invalid', WP_Error $error )
| Parameter | Type | Description |
|---|---|---|
$error |
WP_Error | The error object containing the HTTP status code and error message from the server. |
Example: notify the admin on permanent invalidation
add_action( 'wplf_client_license_invalid', function ( $error ) {
// Send a one-time email to the site admin when the licence becomes invalid
$sent_key = 'acmeforms_invalid_notice_sent';
if ( get_option( $sent_key ) ) {
return; // Already notified
}
wp_mail(
get_option( 'admin_email' ),
'AcmeForms Pro: Licence Invalid',
sprintf(
"Your AcmeForms Pro licence is no longer valid.\n\nError: %s\n\nPlease renew or re-enter your licence key.",
$error->get_error_message()
)
);
update_option( $sent_key, true );
} );
wplf_client_update_available
Fires when the updater detects that a new version is available on the LicenceForge server.
Signature
do_action( 'wplf_client_update_available', object $update_data )
| Parameter | Type | Description |
|---|---|---|
$update_data |
object | The update data object containing new_version, package, package_hash, tested, requires, requires_php, and other fields. |
Example: log available updates
add_action( 'wplf_client_update_available', function ( $update_data ) {
error_log( sprintf(
'AcmeForms Pro: Update available. Current: %s, New: %s',
ACMEFORMS_VERSION,
$update_data->new_version
) );
} );
Summary
| Hook | Type | When it fires |
|---|---|---|
wplf_client_api_args |
Filter | Before every API request to the LicenceForge server. |
wplf_client_is_valid |
Filter | After parsing a validation response, before caching the result. |
wplf_client_cache_duration |
Filter | When storing the validation result in a transient. |
wplf_client_has_feature |
Filter | On every has_feature() call. |
wplf_client_activated |
Action | After successful site activation. |
wplf_client_deactivated |
Action | After successful site deactivation. |
wplf_client_license_invalid |
Action | On permanent validation error (401, 403, 404). |
wplf_client_update_available |
Action | When the updater detects a newer version on the server. |
Next steps
- WordPress Integration (3-Class) -- Full setup and method reference
- Feature Checking -- Gate functionality based on tier and features
- Auto-Updates -- Update delivery and verification pipeline
- Developer Hooks Reference -- Server-side hooks on the LicenceForge installation