stijnb12345
Forum Replies Created
-
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysFixed it. I’m now using the $data variable, and get it from there.
Thanks for your help! It’s working now.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysOkay, at the lmfwc_rest_api_pre_response filter, how to get the key from the URL?
$route returns:
Array ( [0] => v2 [1] => licenses [2] => {license_key} )
- This reply was modified 4 years, 11 months ago by stijnb12345.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysFixed that issue, but the instance is still not added at activation.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keys/** @var \LicenseManagerForWooCommerce\Models\Resources\License $license */ $license = \LicenseManagerForWooCommerce\Repositories\Resources\License::instance()->findBy( array( 'license' => apply_filters('lmfwc_hash', $licenseKey) ) ); if ($license) { $licenseId = $license->getId(); } else { return new WP_Error( 'lmfwc_rest_data_error_12', 'License Key ID invalid.', array('status' => 404) ); }
Now I get the lmfwc_rest_data_error_12 error. The License key is now correct.
- This reply was modified 4 years, 11 months ago by stijnb12345.
- This reply was modified 4 years, 11 months ago by stijnb12345.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keys$licenseKey = sanitize_text_field($request->get_param('license_key'));
This line at the
lmfwc_rest_api_validation
filter is null, what is wrong?Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysHope you had a merry Christmas too!
Yeah, I like to be a PTE.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysI will debug it today.
If you still need any translators for nl_NL (Dutch), I’m here to help you with the translations.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keys{"code":"lmfwc_rest_data_error","message":"License Key invalid.","data":{"status":404}}
I get this error when I go to /lmfwc/v2/licenses/activate/KEY
The KEY is correct and not activated yet.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysOkay, thanks.
So this should be it?
add_filter('lmfwc_rest_api_pre_response', function($method, $route, $data) { // First check if it's the correct route and method using the $method and $route variables // The license data is contained within $data if ($method === 'GET' && substr_count($route, "/") == 4 && strpos($request, 'licenses') !== false) { $licenseKey = sanitize_text_field($request - > get_param('license_key')); if (!$licenseKey) { return new WP_Error( 'lmfwc_rest_data_error_1', 'License Key invalid.', array('status' => 404) ); } $licenseId = false; /** @var \LicenseManagerForWooCommerce\Models\Resources\License $license */ $license = \LicenseManagerForWooCommerce\ Repositories\ Resources\ License::instance() - > findBy( array( 'license' => apply_filters('lmfwc_hash', $licenseKey) ) ); if ($license) { $licenseId = $license - > getId(); } else { return new WP_Error( 'lmfwc_rest_data_error_2', 'License Key ID invalid.', array('status' => 404) ); } $myNewData = lmfwc_get_license_meta($licenseId, "instance", true); $data['instance'] = $myNewData; return $data; } // OR, everything went fine and we just return "true" return true; }, 10, 3); add_filter('lmfwc_rest_api_validation', function($result, $server, $request) { // Perform your validation and checks // create and return a WP_Error object if there is an error // Return anything else if the validation passed // For example: $route = $request - > get_route(); // Returns "/lmfwc/v2/licenses/activate/THE-PRETENDER" for example $method = $request - > get_method(); // Returns "GET" for example // We now know that this is a "Activate license" request, we can now do our validation if ($method === 'GET' && strpos($request, 'activate') !== false) { $licenseKey = sanitize_text_field($request - > get_param('license_key')); if (!$licenseKey) { return new WP_Error( 'lmfwc_rest_data_error', 'License Key invalid.', array('status' => 404) ); } $licenseId = false; /** @var \LicenseManagerForWooCommerce\Models\Resources\License $license */ $license = \LicenseManagerForWooCommerce\ Repositories\ Resources\ License::instance() - > findBy( array( 'license' => apply_filters('lmfwc_hash', $licenseKey) ) ); if ($license) { $licenseId = $license - > getId(); } else { return new WP_Error( 'lmfwc_rest_data_error', 'License Key ID invalid.', array('status' => 404) ); } $instance = sanitize_text_field($request - > get_param('instance')); if (!$instance) { return new WP_Error( 'lmfwc_rest_data_error', 'License Key invalid.', array('status' => 404) ); } lmfwc_add_license_meta($licenseId, "instance", $instance); } // OR, everything went fine and we just return "true" return true; }, 10, 3);
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysAnd just append it to the array which is used for the output, that should be it.
And how do I need to append something to that array in the filter? After I know that, it should work.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keys@drazenbebic Thanks!
And what is that
'YOUR-KEY-HERE!!!'
? And how to get that key?- This reply was modified 4 years, 11 months ago by stijnb12345.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysOkay, thanks!
How do I retrieve the license ID and those values for the
lmfwc_add_license_meta()
method?I expect the values to be with
$_GET
, right?- This reply was modified 4 years, 11 months ago by stijnb12345.
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysYes. Something like this:
/lmfwc/v2/licenses/activate/KEY?consumer_key=…&consumer_secret=…&instance=IP:Port
So I want to save that instance, and then get that instance with /lmfwc/v2/licenses/KEY?……
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysI want to use the API to insert and use that data.
I’m running a system with Java which includes an IP and Port. At the license activation I want to insert that IP and Port and then I want to check that IP and Port with a GET request (/licenses/KEY).
Forum: Plugins
In reply to: [License Manager for WooCommerce] Extra information for license keysThanks.
But I want to set some data at the activation (/lmfwc/v2/licenses/activate/KEY), and then check that data with /lmfwc/v2/licenses/KEY. The check itself doesn’t need to be in the PHP code.