Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter cyberespia

    (@cyberespia)

    Solution: https://github.com/Tmeister/wp-api-jwt-auth/issues/153

    in /plugins/jwt-authentication-for-wp-rest-api/class-jwt-auth-public.php

            $data = array(
                'token' => $token,
                'user_email' => $user->data->user_email,
                'user_nicename' => $user->data->user_nicename,
                'user_display_name' => $user->data->display_name,
                //add this
                'user_id' => $user->data->ID,
            );
    Thread Starter cyberespia

    (@cyberespia)

    Update

    In functions.php to hold the user_id, avatar, role

    function jwt_auth_function($data, $user) { 
    	$data['user_role'] = $user->roles; 
    	$data['user_id'] = $user->ID; 
    	$data['avatar']= get_avatar_url($user->ID);
    	return $data; 
    } 
    	add_filter( 'jwt_auth_token_before_dispatch', 'jwt_auth_function', 10, 2 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How get ID User’ is closed to new replies.