Output user data from custom endpoint
-
Hi
I am probably missing something obvious by how to I get the user data of an authenticated user in a custom endpoint?
function get_user_data( $response ) { // HOW DO I OUTPUT USER DATA HERE? error_log(print_r($response, true)); return 'User'; } add_action( 'rest_api_init', function () { register_rest_route( 'access/v1', '/content/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => 'get_user_data', 'args' => array( 'id' => array( 'validate_callback' => function($param, $request, $key) { return is_numeric( $param ); } ), ), ) ); } );
It is validating successful and I am getting the response but I am not sure how to parse the token to get the user data?
I know with another plugin you do this.
$user = JWTAuth::parseToken()->authenticate()
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Output user data from custom endpoint’ is closed to new replies.