I want to display a WordPress logged in user ID and email in another website so, I'm using the wordpressjson-api
plugin to create an api but it's not working.
When I hit a direct link, it displays data as:
"{\"id\":1,\"email\":\"admin@admin.com\"}"
But when I use json_decode
and print data, it displays:
string(22) "{"id":0,"email":false}"
api code
public function get_loggedin_user_details() {
global $user;
global $wpdb, $json_api;
$current_user = wp_get_current_user();
$myObj->id = $current_user->ID;
$myObj->email = $current_user->user_email;
$logedin_userid = json_encode($myObj);
return $logedin_userid;
}