How to check if user is active patron of specific account?

I’m trying to check a user’s patron_status status for a specific Patreon account based on the response object to an identity request that includes an array of memberships. Each membership in the array looks something like this (in JSON);

{
  "attributes": {
    "currently_entitled_amount_cents": 0,
    "last_charge_date": "2020-01-01T22:09:27.000+00:00",
    "last_charge_status": "Paid",
    "lifetime_support_cents": 25000,
    "patron_status": "active_patron",
    "pledge_relationship_start": "2019-01-01T14:03:03.380+00:00"
  },
  "id": "xxxx-xxxx-xxxx-xxxx-xxxx",
  "type": "member"
}

So I’m checking the value of patron_status on the object for the Patreon account I want to check the user’s status on. I’m assuming that I can look this up by the id on the object, but I’m not really sure. I don’t know how to determine a Patreon account’s id, other than the username. But I’m also not sure if the id on this object is actually referring to the relationship, not to the Patreon account.

When I have a memberships array with objects like this, what is the easiest way to check if a user is an active Patron of a specific Patreon account?

For clarity, what I’d like to check is “Is the currently authenticated Patreon user a patron of https://www.patreon.com/localjo ?”.

Also for clarity, I am building a plugin that will work together with the Patreon Connect plugin to check if the currently authenticated Patreon user (the one logged into the WordPress admin with Patreon) is an active patron of another specific Patreon user (in this case, my own, but in general, I hope to make this plugin work for anyone with a similar use-case).

In such a case you would need to have permission from the user to see his/her patronages. Via user’s own auth token created while registering for your site. It shouldnt be possible to do by using only your creator access token.

1 Like

@codebard Can you clarify the user flow for this? This is what I’m thinking;

  1. A user installs the Patreon plugin and connects their WordPress login to their Patreon account.

  2. Then, the user installs my plugin which uses their own connection to Patreon to check if they’re a patron of mine (or of another developer who writes a plugin with the same flow).

  3. If the authenticated Patreon user is a patron of the developer, they will have access to some patron-only plugin features.

Will this flow work? Does the auth token the user gets when they connect Patreon to their WordPress account have the needed permission? If not, is there any way to extend the access or ask for more permissions? Or will I need to have the user create a completely new access token? (In which case, maybe the existing Patreon plugin wouldn’t be needed for what I want to do, and I should re-implement everything for my plugin).

What are your thoughts?

I seem to have missed this post of yours sorry - just saw it.

In the scenario you describe you would still need to distribute creator access token or create apps for users. Because, your plugin will need to check for patronage of user to your account. So its still a complication.

A better way could be doing it how some plugin houses in WP space are doing: have the user install a ‘dashboard’ or ‘X connect’ plugin to connect their site to an auth service you run at your place, and then do your checks from there.

Like how WPMU does with their dashboard plugin. You can just have the user log into your website via Patreon. Also have the user connect their site to your website via your dashboard plugin. And then you can check that user’s info by checking whatever auth id which the user’s site has, then checking it from the local info at your website and matching the Patreon user, and then concluding Patreon status of the user.

This way you dont distribute your creator access token.

Thank you for the response.

I guess I was thinking of embedding the creator access token (my token) in the code of the plugin itself, which would then check the Patreon API to see whether the user was a Patron of mine. But I can see why distributing my access token in the plugin’s code is a bad idea.

I’ve been trying to figure out some way of allowing a plugin to check if a user is a Patron of mine, so I can enable premium features only for Patrons. But I don’t want to run or maintain my own server for this, since the plugin is already running on a server. But I’m thinking now that this isn’t the best approach, for a variety of reasons.

Instead, I think I’ll just offer a premium version of my plugin to my Patrons as a separate download. Less automatic than I would like, but it costs a lot less than maintaining a server which right now would eat up any of the support I’m getting from Patrons.

Instead, I think I’ll just offer a premium version of my plugin to my Patrons as a separate download. Less automatic than I would like

This may be a better option to start - and there are already tools for it (like Easy Digital Downloads etc) and WP ecosystem has awareness of this business model - ie its the normal.

Im also distributing Patron Plugin Pro via the same mechanic via Codebard:

It uses EDD, with software licencing. What i added extra has been a specific update server which checks valid licenses and then distributes updates. This could have been done via EDD, but i wanted to implement my own update mechanism. Using EDD and its addons you could easily get going with this format.