Tmeister / wp-api-jwt-auth

A simple plugin to add JSON Web Token (JWT) Authentication to WP REST API
GNU General Public License v2.0
560 stars 161 forks source link

how can we know from the jwt token the userId of the user? #203

Open sarah-geara opened 4 years ago

sarah-geara commented 4 years ago

Is there a way or a reverse way to know from the jwt token returned the userId of the user loggedIn ?

pesseba commented 3 years ago

You must use a filter to extend the plugin:

add_filter('jwt_auth_token_before_dispatch', function( $data ){
    $data['user_id'] = get_current_user_id();
    return $data;
} ,10,1);