• Resolved Mian Shahzad Raza

    (@mianshahzadraza)


    Hi,
    is there a way to check license key if it’s valid or not? I mean the key which is not activated yet, just to see if the entered value is a valid key or not.
    Also any option to see license activations in admin dashboard or a query to db for retrieving that information with a custom plugin?

Viewing 1 replies (of 1 total)
  • Plugin Contributor 10Quality

    (@10quality)

    Also any option to see license activations in admin dashboard

    Using the www.ads-software.com version no. But with our paid extension yes (here), it comes with manage pages to view and edit customer license keys from the admin dashboard.

    is there a way to check license key if it’s valid or not? I mean the key which is not activated yet, just to see if the entered value is a valid key or not.

    With the api no, since the activation endpoint already does the process and there is not need to do a previous request just to validate.

    But if you wish to do this, you can accomplish this by using the LicenseKey model class:

    <?php
    use LicenseKeys\Models\LicenseKey;
    
    if ( LicenseKey::find( '[a-customer-license-key]' ) ) {
        // FOUND
    } else {
        // NOT FOUND
    }
    

    a query to db for retrieving that information with a custom plugin?

    You can always use the model explained above to query the db, the model uses the FindTrait.php, which you can review, to provided proven query functionlity.

    An example:

    <?php
    use LicenseKeys\Models\LicenseKey;
    
    $license_keys = LicenseKey::fromOrder( $order_id );
    

    If you wish to extend the query functionality to add custom queries you can do this bu creating you own model that extends from the existing one:

    <?php
    use WPMVC\MVC\Collection;
    use LicenseKeys\Models\LicenseKey as Model;
    
    class MyLicenseKey extends Model
    {
        public static function all()
        {
            $license_keys = new Collection;
            // TODO QUERY CODE
            return $license_keys;
        }
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Check for valid key’ is closed to new replies.