Issue
I have a wordpress website where react is used for all the front end components. I need to somehow fetch the currently logged-in user's id using the wordpress REST API via an ajax request. The request to the REST API needs to be authenticated in order to get this information but not sure how without the user's credentials in the first place.
Thanks in advance.
Solution
You can fetch a list of all the users using the Wordpress Rest api
and then filter the result of a particular user based on your criteria.
Ref:- Fetch all users
Alternatively, You can fetch current user using this endpoint from the rest API provided by wordpress.
Ref:- Fetch current user
Answered By - Akshay Mathur
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.