1. Home
  2. Docs
  3. WooCommerce License Keys
  4. Developers
  5. Activation Data

Activation Data

WooCommerce License Keys allows for custom activation data to be stored during api calls.

Additional activation data might be needed, for instance, in order to save the serial number of a device or similar.

During activation hook


This filter hook contains all the meta data, related to an activation, that is going to be saved in the database during the activate endpoint.


Array holding all the meta data related to the activation. By default: $meta[‘domain’], $meta[‘ip’] and $meta[‘date’] (unix timestamp which also represents the id).

Array holding all the data sent in the request (See Customize API for more info).


Filter expects $meta array to be returned back.

Code Sample

For explanation purposes, the next code snippet will use the hook above to add the serial number, captured in the request (see Customize API Request to understand how to capture additional request data), as part of the activation’s meta data. 

add_filter( 'woocommerce_license_key_activation_meta', function( $meta, $request ) {

    $meta['serial_number'] = $request['serial_number'];

    return $meta;

}, 10, 2 );

During validation hook


The action hook used during the validation endpoint is different, the API doesn’t save any request data during this endpoint, so you will need to add the logic if you wish to do so.


object | LicenseKeys\Models\LicenseKey
License Key data model.

Activation ID.

Code Sample

For explanation purposes, the next code snippet will use the hook above to update the serial number used in the code sample above. 

add_action( 'woocommerce_license_key_activation_validated', function( $license_key, $activation_id ) {

    $uses = $license_key->uses;

    foreach ( $uses as $key => $activation_meta ) {

        if ( $activation_meta['date'] === $activation_id ) {
            $uses[$key]['serial_number'] = \WPMVC\Request::input( 'serial_number' );

    $license_key->uses = $uses;

}, 10, 2 );

In templates

Once stored, custom activation data can be used and display in templates (see templating).

Was this article helpful to you? Yes No