• Resolved Theo Gkitsos

    (@theogk)


    Hello,

    I use the REST API to get license info, using the v2/licenses/{license_key} endpoint. I want to filter the response data so I found the lmfwc_rest_api_pre_response filter.

    There are 2 problems:

    1. The arguments for the protected function response function are in the wrong order. When you call this function from inside public function getLicense , you pass the arguments in this order: success, data, code, route. But in the response() function, the arguments for route and code are inverted. So the $route parameter has the value of $code and vice versa. So when I try to use the ‘lmfwc_rest_api_pre_response’, the $route parameter has the value “200” which is totally useless, and not the api route, so I can filter only the kind of request I want.
    2. The other problem (not exactly problem because it works), is that the filter is written in a wrong way. If you check the doc https://developer.www.ads-software.com/reference/functions/apply_filters/ you will see that the first parameter is the $hook_name, the SECOND is the VALUE to filter, and all the rest are just other args to help us filter more precisely. So the problem is in the second parameter, which should be the $data, and after that the $route and $_SERVER[‘REQUEST_METHOD’] should follow (3rd and 4th). This is why you have to use the add_filter(‘lmfwc_rest_api_pre_response’, array($this, ‘preResponse’), 1, 3); in the api setup, and add a filter in your own hook which is totally unneeded if the apply_filters function is written correctly. But probably you already know this, but you don’t want to change your codebase that much.

    I would be grateful if you could fix at least the main problem (1) which the wrong arguments order. This is a fairly simple fix, is it possible that you can make it happen any time soon?

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Ibaad Ahmed Khan

    (@ibaad06)

    Hello @theogk

    Sorry for the inconvenience caused. We appreciate you taking the time to point out these issues. Your feedback is invaluable to us as it helps us improve our product. Rest assured, we’re committed to addressing these concerns, and as a result, we’ll be releasing an update for the free version that includes these fixes.

    Kind Regards.

    WP-Experts.

    Thread Starter Theo Gkitsos

    (@theogk)

    Thank you very much, I really appreciate it.

    Theo

    Plugin Support Ibaad Ahmed Khan

    (@ibaad06)

    Dear @theogk

    The new version 3.0.7 has been released with the latest updates and fixes. Thank you for pointing out these issues; your feedback has been invaluable to us.

    Thank you and Kind Regards.

    WP-Experts.

    Thread Starter Theo Gkitsos

    (@theogk)

    Thanks for the update. It works fine now.

    There is only a PHP deprecation warning in the response method because a required parameter is after an optional, but it’s ok. You can consider fixing this in a next version.

    Plugin Support Ibaad Ahmed Khan

    (@ibaad06)

    Dear @theogk


    We’re glad to hear the update worked for you. Thank you for bringing this issue to our attention. I have forwarded the details to our development team, and we will address it in our next version update.

    Kind regards,

    WP-Experts

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.