Skip to content

Functions

WPLM exposes a set of global functions that wrap the internal services. They return typed objects (or WP_Error) and are safe to call from themes and other plugins after plugins_loaded.

FunctionPurpose
wplm_create_license( $args )Create & return a License (signs the key, encrypts, stores).
wplm_get_license( $key )Fetch a License by key string or id.
wplm_get_licenses( $args )Query licenses with filters.
wplm_update_license( $key, $data )Update writable fields.
wplm_delete_license( $key )Delete a license.
wplm_validate_license( $key, $fingerprint = null )Run full validation; returns a result array.
wplm_renew_license( $key, $until )Extend expiry.
wplm_revoke_license( $key )Revoke a license.
wplm_suspend_license( $key )Suspend a license.
wplm_reinstate_license( $key )Reinstate a suspended/revoked license.
wplm_terminate_license( $key )Irreversibly terminate.
$result = wplm_validate_license( 'ABCD-EFGH-IJKL-MNOP', $fingerprint );
if ( $result['valid'] ) {
// unlock features
}
FunctionPurpose
wplm_activate_device( $key, $fingerprint, $meta = [] )Activate a device; returns Machine or WP_Error.
wplm_deactivate_device( $key, $fingerprint )Deactivate a device; frees a seat.
wplm_get_devices( $key )List Machine rows for a license.
wplm_revoke_device( $machine_id )Revoke a single device.
wplm_record_heartbeat( $fingerprint, $license_id )Register a device ping.
FunctionPurpose
wplm_create_subscription( $args )Create a subscription + items.
wplm_get_subscription( $id )Fetch a subscription with items + bound license.
wplm_get_subscriptions( $args )Query subscriptions by status/user/product.
wplm_pause_subscription( $id )On-hold the subscription (suspends license).
wplm_resume_subscription( $id )Reactivate a paused subscription.
wplm_cancel_subscription( $id, $at_period_end = false )Cancel now or at period end.
wplm_switch_subscription( $id, $new_plan )Upgrade/downgrade with proration.
wplm_process_renewal( $id )Charge a renewal immediately via the gateway token.
FunctionPurpose
wplm_add_license_meta( $id, $key, $val )Add a meta row.
wplm_get_license_meta( $id, $key )Get a meta value.
wplm_update_license_meta( $id, $key, $val )Update meta.
wplm_delete_license_meta( $id, $key )Delete meta.
wplm_blacklist_add( $type, $value, $reason )Add to a deny list.
wplm_generate_keys( $generator_id, $count )Bulk-generate unique keys.