After a license has been been activated, it can also be deactivated remotely. Usually the reason to deactivate a license is to permit a license to be activated on an additional site once the activation limit has been reached.
Before reading this documentation, please read through the instructions for how to activate a license.
The deactivation process is nearly identical to the activation process. We perform a remote request and send the details of the license key we are deactivating. The remote request is done like so:
$api_params = array( 'wpls_action' => 'deactivate', 'license' => $license, 'code' => urlencode( WPLS_SAMPLE_ITEM_CODE ), // the CODE of our product in WPLS 'url' => home_url(), 'host' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'] ); // Call the custom API. $response = wp_remote_get( add_query_arg( $api_params, WPLS_SAMPLE_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
The $response var will be a json object that tells us whether the deactivation request was successful or not. If it is successful, the response will be:
{ "license_status": "deactivated", "item_name": "WPLS Product name", "license_type": "BASIC", "expires": "2015-01-01 00:00:00", "payment_id": 'inv-df4396cc2dea8b50125007a909b1292e', "customer_name": "John Doe", "customer_email": "[email protected]" }
If the license fails to be deactivated, the response will be:
{ "license_status": "invalid", "item_name": "WPLS Product name", "license_type": "BASIC", "expires": "2015-01-01 00:00:00", "payment_id": 'inv-df4396cc2dea8b50125007a909b1292e', "customer_name": "John Doe", "customer_email": "[email protected]" }
Once a license has been successfully deactivated, the Counter column in Licensing System > License Dashboard will be decremented and an entry will be recorded in the log so that admins can see where a license was deactivated from.