Title: Filter changed, limit no of generated license keys for order
Last modified: November 20, 2019

---

# Filter changed, limit no of generated license keys for order

 *  Resolved [mihailj](https://wordpress.org/support/users/mihailj/)
 * (@mihailj)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/filter-changed/)
 * Hello,
 * I’m using the License Manager for WooCommerce plugin (great work by the way Drazen!)
   in a webshop where for any number of products in an order only one license key
   is needed (story: I sell a number of users licenses that can be activated on 
   their accounts in my system with the same license key).
 * Therefore I’ve hooked to the **lmfwc_create_license_keys** filter on _2.0.1_ 
   version to limit the number of generated license keys to a single one like this:
 * > function limitGeneratedLicenseKeys($params) {
   >  $params[‘amount’] = 1; return
   > $params; } add_filter( ‘lmfwc_create_license_keys’, ‘limitGeneratedLicenseKeys’,
   > 10);
 * But after the update to _2.1.0_ I had the surprise that this wasn’t working anymore,
   so I’ve checked the source code of LMFWC and saw that the filter name was changed
   to **lmfwc_generate_license_keys** with totally different parameters. So I’ve
   changed my hook like this:
 * > function limitGeneratedLicenseKeys($amount, $generator, $licenses = array()){
   > 
   > $new_licenses = array_slice($licenses, 0, 1); return $new_licenses; } add_filter(‘
   > lmfwc_generate_license_keys’, ‘limitGeneratedLicenseKeys’, 25, 3);
 * But there seems to be a problem that I can’t figure out how to fix, the licenses
   are actually in the first parameter **$amount**?! For now I’ve changed my code
   to _array\_slice_ the **$amount** parameter instead of **$licenses**. But I am
   very curious if anyone else is experiencing this and why it’s happening – going
   through LMFWC source code I didn’t notice any weird function arguments order 
   change.
 * Also I have a suggestion for you Drazen, would be great to have an option built
   in the plugin to limit the number of generated license keys for an order so I
   don’t have to rely on these hacks that can break on a plugin update.
 * Thanks,
    Mihail
    -  This topic was modified 6 years, 6 months ago by [mihailj](https://wordpress.org/support/users/mihailj/).
      Reason: changed title

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Drazen Bebic](https://wordpress.org/support/users/drazenbebic/)
 * (@drazenbebic)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/filter-changed/#post-12156512)
 * Hello [@mihailj](https://wordpress.org/support/users/mihailj/),
 * thank you for your message and for using my plugin.
 * I actually just realized, that the filter will never work the way it used to 
   because I decided to split the variables into different function parameters. 
   I will have to rethink this part.
 * Let me just understand your scenario right: Every customer order in your webshop
   comes with a single license key, regardless of the product or its quantity. Then,
   this once license key is used to activate all of those products. Am I correct
   so far?
 *  [Drazen Bebic](https://wordpress.org/support/users/drazenbebic/)
 * (@drazenbebic)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/filter-changed/#post-12207325)
 * Hello [@mihailj](https://wordpress.org/support/users/mihailj/),
 * do you still need help with this?
 *  [Drazen Bebic](https://wordpress.org/support/users/drazenbebic/)
 * (@drazenbebic)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/filter-changed/#post-12217594)
 * I’ll mark this as resolved, due to inactivity.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Filter changed, limit no of generated license keys for order’ is closed
to new replies.

 * ![](https://ps.w.org/license-manager-for-woocommerce/assets/icon-256x256.gif?
   rev=2824216)
 * [License Manager for WooCommerce](https://wordpress.org/plugins/license-manager-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/license-manager-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/license-manager-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/license-manager-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/license-manager-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/license-manager-for-woocommerce/reviews/)

## Tags

 * [serial](https://wordpress.org/support/topic-tag/serial/)
 * [serial key](https://wordpress.org/support/topic-tag/serial-key/)

 * 3 replies
 * 2 participants
 * Last reply from: [Drazen Bebic](https://wordpress.org/support/users/drazenbebic/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/filter-changed/#post-12217594)
 * Status: resolved