lmfwc_rest_api_pre_response return 500 error
-
Hello !
I try to use the hook in your documentation to set remote addr in activation request:
function lmfwc_tutorial_modify_response($method, $route, $data) { // First check if we are on the correct route if ($route !== 'v2/licenses/activate/{license_key}') { return $data; } ? // Now we will save an activation object for this license/activation. The // activation object will be an array consisting of an ID, the proxy (if // The remote party is using a proxy), and the user's remote address (IP). // Please note that we're just using the PHP "uniqid()" method for the ID, // you can of course use something more appropriate. $activation = array( 'id' => uniqid(), 'http_x_forwarded_for' => $_SERVER['HTTP_X_FORWARDED_FOR'], 'remote_addr' => $_SERVER['REMOTE_ADDR'] ); ? // Save to the license meta lmfwc_add_license_meta($data['id'], 'activation', $activation); ? // Add the $activation variable to the response $data['activation'] = $activation; ? // Return the result return $data; } add_filter('lmfwc_rest_api_pre_response', 'lmfwc_tutorial_modify_response', 10);
when I fetch the endpoint i get an error 500 :
{ "code": "internal_server_error", "message": "<p>Il y a eu une erreur critique sur ce site.</p><p><a href=\"https://fr.www.ads-software.com/support/article/debugging-in-wordpress/\">En apprendre plus sur le débogage de WordPress.</a></p>", "data": { "status": 500 }, "additional_errors": [] }
Obviously the problem comes from the arguments passed to the function, can you help me?
Thank you so much !
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘lmfwc_rest_api_pre_response return 500 error’ is closed to new replies.