Title: Decrypted License key
Last modified: November 8, 2021

---

# Decrypted License key

 *  Resolved [dimitrislalas](https://wordpress.org/support/users/dimitrislalas/)
 * (@dimitrislalas)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/)
 * I have trounble with the apply filters for decrypting the license key. I want
   to do some customizations within the functions.php file of wordpress but the 
   function getDecryptedLIcenseKey throws me the license key encrypted. I tried 
   doing the add_action after setup theme and plugins_loaded but still i get the
   key encrypted

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

 *  [A.Tariq](https://wordpress.org/support/users/arsalantariq/)
 * (@arsalantariq)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15047172)
 * Hi [@dimitrislalas](https://wordpress.org/support/users/dimitrislalas/)
 * Hope you are well.
 * What do you want to achieve firstly as getDecryptedLicenseKey works on license
   object if you have the license object you can call the licenseOBJ->getDecryptedLicenseKey();
   like this but first you should have the license object. Which filter are you 
   using for decrypting the license?
 * Thanks
 *  Thread Starter [dimitrislalas](https://wordpress.org/support/users/dimitrislalas/)
 * (@dimitrislalas)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15047663)
 * add_action(‘after_setup_theme’,’doit’)
    function doit(){ $uid = get_current_user_id();
 *  /** [@var](https://wordpress.org/support/users/var/) LicenseResourceModel[] 
   $licenses */
    $licenses = LicenseResourceRepository::instance()->findAllBy(array(‘
   created_by’ => $uid));
 *  $response = array();
    $check= array(); foreach ($licenses as $license) { //$
   licenseData = $license->toArray(); // Remove the hash, decrypt the license key,
   and add it to the response // unset($licenseData[‘hash’]); // $licenseData[‘licenseKey’]
   = $license->getDecryptedLicenseKey(); $check[0]=”; $check[]= $license-> getCompanyName();//
   apply_filters(‘lmfwc_decrypt’,$key); //$response[] = $licenseData[‘licenseKey’];
   $response[] = $license->getDecryptedLicenseKey(); }
 *  if($check[1]!=null){
    wpas_add_custom_field( ‘cp_name’, array( ‘title’ => __(‘
   Select your Company Name’, ‘wpas’ ), ‘field_type’ => ‘select’, ‘log’ => true,‘
   show_column’ => true, ‘show_frontend_detail’ => true, ‘sortable_column’ => true,‘
   required’ => true, ‘options’ => $response ) );}else{ wpas_add_custom_field( ‘
   cpname’, array( ‘title’ => __( ‘Select your Company Name’, ‘wpas’ ), ‘field_type’
   => ‘select’, ‘show_column’ => true, ‘show_frontend_detail’ => true, ‘sortable_column’
   => true, ‘required’ => true, ‘options’ => array( ”=> ‘You dont have any products
   attached to a company name!’) ) );
 *  }
    }}
    -  This reply was modified 4 years, 7 months ago by [dimitrislalas](https://wordpress.org/support/users/dimitrislalas/).
 *  Thread Starter [dimitrislalas](https://wordpress.org/support/users/dimitrislalas/)
 * (@dimitrislalas)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15047707)
 * I am trying to implemend this code to the functions.php file. And at the output
   i get the license key encrypted
 *  [A.Tariq](https://wordpress.org/support/users/arsalantariq/)
 * (@arsalantariq)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15057535)
 * [@dimitrislalas](https://wordpress.org/support/users/dimitrislalas/) let me look
   into this and get back to you soon.
 *  [A.Tariq](https://wordpress.org/support/users/arsalantariq/)
 * (@arsalantariq)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15058616)
 * [@dimitrislalas](https://wordpress.org/support/users/dimitrislalas/)
 * Use LicenseManagerForWooCommerce\Repositories\Resources\License as LicenseResourceRepository;
 * add_action(‘init’,’doit’);
    function doit() { $uid = get_current_user_id();`
 *     ```
       /** @var LicenseResourceModel[] $licenses */
       $licenses = LicenseResourceRepository::instance()->findAllBy(array('created_by' => $uid));
   
       $response = array();
       foreach ($licenses as $license) {
       $response[] = $license->getDecryptedLicenseKey();
       }
       ```
   
 * Thanks
 *  Thread Starter [dimitrislalas](https://wordpress.org/support/users/dimitrislalas/)
 * (@dimitrislalas)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15062106)
 * Thats perfect! It worked! Thank you very much. I search everythhing about what
   i should do with the add_action call but i couldnt find the right one.
 *  [A.Tariq](https://wordpress.org/support/users/arsalantariq/)
 * (@arsalantariq)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15067952)
 * [@dimitrislalas](https://wordpress.org/support/users/dimitrislalas/) great … 
   thanks

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

The topic ‘Decrypted License key’ 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/)

 * 7 replies
 * 2 participants
 * Last reply from: [A.Tariq](https://wordpress.org/support/users/arsalantariq/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/decrypted-license-key/#post-15067952)
 * Status: resolved