How to create a License using PHP

To create a License, you can utilize the Digital License Manager’s utility functions as follows:

<?php

$license = dlm_create_license( 'AAAA-AAAA-AAAA-AAAA', [
	'order_id'          => 100, // optional
	'user_id'           => 2, // optional
	'product_id'        => 4, // optional
	'status'            => \IdeoLogix\DigitalLicenseManager\Enums\LicenseStatus::ACTIVE, // ACTIVE, DELIVERED, DISABLED, INACTIVE, SOLD
	'source'            => \IdeoLogix\DigitalLicenseManager\Enums\LicenseSource::API, // API, IMPORT, MIGRATION, GENERATOR
	'expires_at'        => '2025-10-15 11:00:00',
	'activations_limit' => 2,
] );

if ( is_wp_error( $license ) ) {
	echo $license->get_error_message();
} else {
	echo "License ID: ".$license->getId(); // success.
}