Software Licensing – WordPress Filters and Actions

Software Licensing is an extension for Easy Digital Downloads that makes it easy to license your digital products. Learn more at the main Easy Digital Downloads website.

Just like Easy Digital Downloads core, the Software Licensing add-on includes a variety of action and filter hooks that you can use to tweak the behavior of the extension to better suit your needs. This documentation is written for advanced users that are already familiar with the  WordPress Plugins API.

License Creation

License Length

By default, every license key is given a one year expiration date. This expiration length can easily be changed by using the  edd_sl_license_exp_length filter. There are four parameters passed to the filter:

  • $length (string) - The expiration length for this license. "+1 year" is default
  • $payment_id (int) - The payment ID of the purchase this license was generated with
  • $download_id (int) - The download/product ID this license is connected to
  • $license_id (int) The ID of the newly created license

Here's a quick example of how you might change the expiration length:

Execute Functions After License Creation

The  edd_sl_store_license action is fired just after the license key is created and all meta data is attached to it. The action takes three parameters:

  • $license_id (int) - The ID of the newly created license
  • $download_id (int) - The ID of the download/product this license is connected to
  • $payment_id (int) - The ID of the purchase this license was created with

A sample function you might attach to this action could look something like this:

Execute Functions During License Activation

The  edd_sl_activate_license action runs just after a license is activated via the API.

do_action( 'edd_sl_activate_license', $license_id, $download_id );

Execute Functions During License Checking

The  edd_sl_check_license action runs just after a license is checked via the API.

do_action( 'edd_sl_activate_license', $license_id, $download_id );

Other Filters

edd_sl_license_response - applied to the response sent when remotely checking a download/product version.

edd_sl_get_license_logs - applied when the log entries for a license are retrieved.

edd_sl_encoded_package_url - applied when the encoded package URL for download packages is retrieved.

edd_sl_download_package_url - applied when the download package file for auto updates is retrieved.

edd_license_labels - applied to the post type labels when registering the edd_license post type.

Other Actions

edd_sl_before_package_download - executes just before the download file for auto upgrades is served to the browser.