1

In a custom REST API method, I would like to identify the user (typically get_current_user_id() then retrieve their data from database (things like they're role and some custom permission).

But so far get_current_user_id() returns 0 (which is not the current user ID).

Is it possible to identify user in REST API?

Otherwise, a solution I see is using a page as "sort of" API ... but I think that would be an ugly solution.

-1

Are you looking for the WP Rest API User Endpoints?

https://developer.wordpress.org/rest-api/reference/users/

  • 2
    If I'm not mistaking, this looks like WordPress API to find and manage user data. That's not what I'm looking for, I'm trying to write a custom REST API to go with a plug-in, and inside its code, I want to identify the user who makes that API request. I've add the word "custom ... method" in question because maybe it sounded like I was referring to something else. – TTT Apr 10 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.