Create License – PickPlugins

Create License

you can create license under any action by calling method create_license under class class_license_manager_manage_license

 

function create_license(){

$class_license_manager_manage_license = new class_license_manager_manage_license();

$order_id = 123;
$user_id = 10;
$product_id = 125;
$variation_id = 124;

// Generate license key with unique identifier
$license_key = $order_id.md5(time());

$gmt_offset = get_option('gmt_offset');
$gmt_date = date('Y-m-d', strtotime('+'.$gmt_offset.' hour'));



$args['license_key'] = $license_key;
$args['license_status'] = 'active'; // user following string "pending", "active", "blocked", "expired"
$args['domain_count'] = '10'; //
$args['domains_list'] = array(); // Use array('http://hello.com', 'http://hello2.com')
$args['license_email'] = 'hello@email.com';
$args['user_id'] = $user_id;
$args['order_id'] = $order_id;
$args['product_id'] = $product_id;
$args['variation_id'] = $variation_id;
$args['date_created'] = $gmt_date;
$args['date_renewed'] = $gmt_date;
$args['date_expiry'] = date( 'Y-m-d', strtotime( '+1 years' ) ); // adding 1 year with license create date.
$args['meta_data'] = array(); // You can pass more meta key data by array('meta_key_1'=>'Meta Value 1','meta_key_2'=>'Meta Value 2' )

$create_license = $class_license_manager_manage_license->create_license($args);

var_dump($create_license);
}



add_shortcode('create_license', 'create_license');

Return:

On success:
array('status'=>'success', 'message'=>'License created.');

On Failed
array('status'=>'fail', 'message'=>'License create failed.');