Disable the license key on customer side, when disabling/removing the license key on the server

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

The WooCommerce Software License plugin is an essential tool for licensing downloadable software and applications. It offers a comprehensive solution for integrating a licensing system with your code, ensuring secure and efficient management of software licenses.

This plugin package comes with a sample integration code that demonstrates all the main features, including license activation, deactivation, and status verification on the server side. These capabilities make it easy to implement and manage licensing for your products, providing a seamless experience for both developers and end-users.

One of the standout features of the WooCommerce Software License plugin is its ability to synchronize licensing data status between the server and the client application. When a license key is deactivated or removed, the plugin pings the customer’s domain to disable the key on the client side automatically. This ensures that your software remains protected and compliant with licensing terms at all times.

To enable this synchronization feature, navigate to WooCommerce > Settings > Products > License Products, and check the option labeled “On license deactivate, ping the assigned domain.” This setting ensures that whenever a license is deactivated, the assigned domain is notified, and the corresponding license key is disabled on the client’s system:

Whenever the license key is de-activated or removed, the system calls the assigned license key domain with the following arguments:

  • woo_sl_action  argument with ping-deactivation value.
  • product_unique_id argument with the appropriate value of the licensed product.
  • licence_key argument with the de-activated/removed key.

Specifically, on the application a hook should be implemented to check for such an event and take further actions, per your requirements. The following sample code, simply innactivate the application on the customer side:


add_action ( 'init', 'check_plugin_license_deactivate')
    function check_plugin_license_deactivate()
        {
            if ( isset ( $_GET['woo_sl_action'] )   &&  $_GET['woo_sl_action']  ==  'ping-deactivation' &&  isset ( $_GET['product_unique_id'] )    &&  $_GET['product_unique_id']  ==  WOO_SLT_PRODUCT_ID  &&  isset ( $_GET['licence_key'] )  &&  ! empty ( $_GET['licence_key'] ) )
                {
                    $action_licence_key =   $_GET['licence_key'];
                    
                    $licence_data   =   get_site_option('slt_license');;
                    
                    if ( $action_licence_key    !=  $licence_data['key'] )
                        return;
                    
                    $licence_data   =   array();
                    update_site_option('slt_license', $licence_data);
                }   
            
        }

Such code example is already included in the Demo code which can be found inside the WooCommerce Software License plugin package. This can be easily integrated in the customer code or extended to match the requirements.


Category:

By woocommerce-sl, posted on May 28, 2024

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments