Plugin Author
Bagus
(@contactjavas)
Hey @dankkomcg , thanks for asking.
There’s jwt_auth_payload filter you can use. You can find it in the Description tab in the plugin’s page. You will find the detail there.
Example of usage would be:
/**
* Modify the payload/ token's data before being encoded & signed.
*
* @param array $payload The default payload
* @param WP_User $user The authenticated user.
*
* @return array The payload/ token's data.
*/
add_filter(
'jwt_auth_payload',
function ( $payload, $user ) {
// Modify the payload here.
return $payload;
},
10,
2
);
Let me know if that works for you 🙂
Best,
Bagus
Plugin Author
Bagus
(@contactjavas)
Hi @dankkomcg , jwt_auth_payload filter above is to modify the payload.
There’s also jwt_auth_valid_credential_response filter you can use in case you need to modify the success response when generating a token.
@contactjavas thanks! works fine for me!
Plugin Author
Bagus
(@contactjavas)
Hi @dankkomcg , i’ve updated the plugin to 1.3.0.
There is change to jwt_auth_valid_credential_response filter usage. On previous version (1.2.0), the filter contains full WP_REST_Response. On this 1.3.0 version, it only filters the $response array (not the whole WP_REST_Response).
If you don’t use that filter, then don’t worry. But if you use that filter, please refer to the README/ Details tab.
Best,
Bagus