Title: Check for valid key
Last modified: October 18, 2018

---

# Check for valid key

 *  Resolved [Mian Shahzad Raza](https://wordpress.org/support/users/mianshahzadraza/)
 * (@mianshahzadraza)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/check-for-valid-key/)
 * 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?
    -  This topic was modified 7 years, 8 months ago by [Mian Shahzad Raza](https://wordpress.org/support/users/mianshahzadraza/).

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [10Quality](https://wordpress.org/support/users/10quality/)
 * (@10quality)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/check-for-valid-key/#post-10797170)
 * > Also any option to see license activations in admin dashboard
 * Using the WordPress.org version no. But with our paid extension yes ([here](https://www.10quality.com/product/woocommerce-license-keys/)),
   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](https://plugins.trac.wordpress.org/browser/woo-license-keys/trunk/app/Models/LicenseKey.php)**
   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](https://plugins.trac.wordpress.org/browser/woo-license-keys/trunk/app/Traits/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.

 * ![](https://ps.w.org/woo-license-keys/assets/icon.svg?rev=2078245)
 * [License Keys for WooCommerce](https://wordpress.org/plugins/woo-license-keys/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-license-keys/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-license-keys/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-license-keys/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-license-keys/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-license-keys/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [10Quality](https://wordpress.org/support/users/10quality/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/check-for-valid-key/#post-10797170)
 * Status: resolved