Title: retrieve current user data
Last modified: August 22, 2016

---

# retrieve current user data

 *  [jlooooo](https://wordpress.org/support/users/jlooooo/)
 * (@jlooooo)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/retrieve-current-user-data/)
 * Hi,
 * A logged in user cannot retrieve its own data. When I use GET /users/me only 
   admins get their data. This error is shown in the console: code:json_user_cannot_list,
   message:Sorry, you are not allowed to view this user.
 * In the code I can see this check:
 * `if ( $current_user_id !== $id && ! current_user_can( 'list_users' ) ) {`
 * Is this also necessary for logged in users to retrieve their own data? Or is 
   this overlooked?
 * Anyway. Is there a filter avaiable to let logged in users get their own data?
 * Thanks!
 * [https://wordpress.org/plugins/json-rest-api/](https://wordpress.org/plugins/json-rest-api/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [jlooooo](https://wordpress.org/support/users/jlooooo/)
 * (@jlooooo)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/retrieve-current-user-data/#post-5333181)
 * Anyone an idea about this? How can I let subscribers view their own user data?
   Is there something I am missing? Thank you.
 *  Thread Starter [jlooooo](https://wordpress.org/support/users/jlooooo/)
 * (@jlooooo)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/retrieve-current-user-data/#post-5333182)
 * Ok. It seems to be a bug. In class-wp-json-users.php starting at line 128:
 *     ```
       if ( $current_user_id !== $id && ! current_user_can( 'list_users' ) ) {
       			return new WP_Error( 'json_user_cannot_list', __( 'Sorry, you are not allowed to view this user.' ), array( 'status' => 403 ) );
       		}
       ```
   
 * $current_user_id is a number and $id is a string. Hence, the strict comparison
   in the if statement will always result in true.
 * Could this be updated so both variables are numbers, something like:
 *     ```
       if ( (int)$current_user_id !== (int)$id && ! current_user_can( 'list_users' ) ) {
       			return new WP_Error( 'json_user_cannot_list', __( 'Sorry, you are not allowed to view this user.' ), array( 'status' => 403 ) );
       		}
       ```
   
 * Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘retrieve current user data’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-rest-api_2e3641.svg)
 * [WP REST API (WP API)](https://wordpress.org/plugins/json-rest-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-rest-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-rest-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-rest-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-rest-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-rest-api/reviews/)

## Tags

 * [current user](https://wordpress.org/support/topic-tag/current-user/)

 * 2 replies
 * 1 participant
 * Last reply from: [jlooooo](https://wordpress.org/support/users/jlooooo/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/retrieve-current-user-data/#post-5333182)
 * Status: not resolved