Hi @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
add_action(‘after_setup_theme’,’doit’)
function doit(){
$uid = get_current_user_id();
/** @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!’)
) );
}
}}
I am trying to implemend this code to the functions.php file. And at the output i get the license key encrypted
@dimitrislalas let me look into this and get back to you soon.
@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
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.
@dimitrislalas great … thanks