• Resolved jnicol

    (@jnicol)


    Hi. The lmfwc_add_license function in functions/lmfwc_license_functions.php has a bug. If user_id is supplied in the $licenseData parameter, it will overwrite the product_id:

    if (array_key_exists('product_id', $licenseData)) {
        $productId = $licenseData['product_id'];
    }
    if (array_key_exists('user_id', $licenseData)) {
        $productId = $licenseData['user_id'];
    }

    Furthermore, even if user_id was correctly assigned to a variable, it would still not be written to the database, since the $queryData array is missing the user_id key:

    $queryData = array(
    'order_id' => $orderId,
    'product_id' => $productId,
    'license_key' => $encryptedLicenseKey,
    'hash' => $hashedLicenseKey,
    'expires_at' => $expiresAt,
    'valid_for' => $validFor,
    'source' => LicenseSource::IMPORT,
    'status' => $status,
    'times_activated_max' => $timesActivatedMax
    );

    Here is corrected code:

    if (array_key_exists('user_id', $licenseData)) {
        $userId = $licenseData['user_id'];
    }
    
    // later...
    
    $queryData = array(
    'order_id' => $orderId,
    'product_id' => $productId,
    'user_id' => $userId,
    // etc...
    );
    
    
    • This topic was modified 1 year, 3 months ago by jnicol.
    • This topic was modified 1 year, 3 months ago by jnicol.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @jnicol,

    Thanks for contacting us,

    I hope you are doing well, We have forwarded this to our technical team and we will get back to you soon.

    Thanks & Regards

    WP Experts Support Team

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @jnicol,

    We have added the code in our plugin and we will add this in an upcoming release.

    Thank you

    • This reply was modified 1 year, 3 months ago by Mirza Hamza.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug report: lmfwc_add_license function’ is closed to new replies.