How to use the WP REST API to give access

You can add Leaky Paywall user meta to the WP REST API user endpoint.  When enabled, this gives you access to the following data:

  • level_id
  • subscriber_id
  • price
  • plan
  • created
  • expires
  • has_access
  • payment_gateway
  • payment_status

Under Leaky Paywall > Settings > General you can choose to enable the REST API setting.  When enabled, this will automatically add the Leaky Paywall meta data to the WP REST API user endpoint.

Here is an example of the returned data.

How To Use The WP REST API to Give Access

1. You will need authentication to view user data via the WP REST API. If you are looking for an easy way to authenticate with the WP REST API, you could try this plugin. https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/

2. You can search for a user via their email address.  e.g. https://example.com/wp-json/wp/v2/users/[email protected]

3. The documentation for this plugin shows how find the endpoint to authenticate, then you can use your User endpoint. https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/

4. Once you have authenticated and accessed the user, you can use the "has access" value to know if the subscriber has access or not.

Still need help? Contact Us Contact Us