'Woocommerce Membership REST API check if user has a membership plan
I ma developing a mobile app with a wordpress backend that was developed by someone else and the person is unreachable. I have the usual Woocomerce membership plans built on the backend. The website works perfectly fine. The issue is this
I checked the REST API endpoints through 'discovery' and found all the usual endpoints, but my issue is how will i test the if the user has a membership plan via REST API. I have already wasted a lot of time figuring out the solution.
- /wc/v3/memberships lists all the endpoints
- /wc/v3/memberships/plans/ lists all the plans
when i make a call to all these endpoints, it gives me all the users which have memberships.
My question is how would i know if the current loggedin user has purchased a membership, there is no such specific endpoint to it, plus the docs are not very specific. They are vaugue. Good enough for a beginner but not for a production level.
This is the url which i am referring to, which i got from the "official" Woocomerce Membership website https://skyverge.github.io/woocommerce-memberships-rest-api-docs/#get-user-memberships
Solution 1:[1]
Use this endpoint : GET http://example.com/wp-json/wc/v3/memberships/members/ Just replace with current user id. you can get current user id through this endpoint : GET http://example.com/wp-json/wp/v2/users/me
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Siavash |
