Hello @naumanahmed19,
Just remove the if(function_exists... and it should work.
Your code should be like this:
add_action( 'simple_jwt_login_jwt_payload_auth', function($payload, $request){
$payload['name'] = 'joe doe';
return $payload;
}, 10, 2);
Best regards,
Nicu.
Thread Starter
Nomi
(@naumanahmed19)
oh thanks, just a stupid mistake
HI, Nice and good plugin, have a problem for add extra data on payload
– i have activate the hook
– add in functions.php :
add_action( ‘simple_jwt_login_jwt_payload_auth’, function($payload, $request){
$payload[‘name’] = ‘joe doe’;
return $payload;
}, 10, 2);
And when i call
https://xxxxx.com/?rest_route=/simple-jwt-login/v1/auth&email=xxxxr&password=xxxx
it’s always return
{
“success”: true,
“data”: {
“jwt”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDU4NjYyNjgsImV4cCI6MTYwNTg2OTg2OCwiZW1haWwiOiJSb21haW5AdmlsbGF1bWUuZnIiLCJuYW1lIjoiam9lIGRvZSJ9.oslp8UA_T74RrqaFeEKJc6RsZtlG9XzZHnEX8n_1jqY”
}
}
I have my token and succes 🙂 but not extra data 🙁
Hi,
just quick help for @angelzeke. It is not an action but a filter
Hello,
I’ve just decoded your JWT with https://jwt.io and the payload looks like this:
{
"iat": 1605866268,
"exp": 1605869868,
"email": "....",
"name": "joe doe"
}
Just copy your JWT on this website, and you can view the payload.
Another option is, to base64 decode the second segment of the JWT ( segments are separated by dots. Example: header.payload.signature )
Let me know if you have other questions.
Best regards,
Nicu.