How to add other variables in the API response?
-
Hello, when I make a request the response carries this information:
{ "token": "example_token", "user_email": "[email protected]", "user_nicename": "example-pw", "user_display_name": "example-user", }
I need to add
user_id
as a variable included in the response, I have edited in this filepublic/class-jwt-auth-public.php
and in the line num#196
I have edited this code:/** The token is signed, now create the object with no sensible user data to the client*/ $data = [ 'token' => $token, 'user_email' => $user->data->user_email, 'user_nicename' => $user->data->user_nicename, 'user_display_name' => $user->data->display_name, ];
to this code:
/** The token is signed, now create the object with no sensible user data to the client*/ $data = [ 'token' => $token, 'user_email' => $user->data->user_email, 'user_nicename' => $user->data->user_nicename, 'user_display_name' => $user->data->display_name, 'user_id' => $user->data->user_id, 'userId' => $user->data->id, ];
I have tried
$user->data->user_id
and$user->data->id
but the code didn’t work the response back NULL in theuser_id
anduserId
this is the response:
{ "token": "example_token", "user_email": "[email protected]", "user_nicename": "example-pw", "user_display_name": "example-user", "user_id": null, "userId": null, }
Any help please?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.