[OAuth2] Get tier names

Hey there I’m working on making a MediaWiki extension which integrates patreon. I’m having trouble getting the tier name (I assume free trial would be treated similar to paid) I’m new to this thanks.

public function fetch_user() {
    return $this->__get_json(
         "identity?include=memberships.currently_entitled_tiers,memberships.campaign&fields[user]=email,first_name,full_name,image_url,last_name,thumb_url,url,vanity,is_email_verified&fields[member]=currently_entitled_amount_cents,lifetime_support_cents,campaign_lifetime_support_cents,last_charge_status,patron_status,last_charge_date,pledge_relationship_start,pledge_cadence"
   );
}

public function fetch_tier_names($user_data) {
        // Create an array to hold the tier names
        $tier_names = [];

        $tier_ids = [];
        foreach ($user_data['data']['relationships']['memberships']['data'] as $membership) {
            foreach ($membership['relationships']['currently_entitled_tiers']['data'] as $tier) {
                $tier_ids[] = $tier['id'];
            }
        }

        foreach ($user_data['included'] as $tier_data) {
            if ($tier_data['type'] === 'tier' && in_array($tier_data['id'], $tier_ids)) {
                $tier_names[] = $tier_data['attributes']['name'];
            }
        }

        return $tier_names;
    }

im having similir issue, the pledge cant be found or nothing is store in the plugin data.

I found a loophole by making a seprate page that is locked for tier members only, then I array that page to be checked if its locked then an element or page is hidden. see exmaple of the code;

Step 1: Create a Hidden Page

  • Make a new page in WordPress called something like:
    4K Check – DO NOT INDEX
  • Add a simple shortcode to it like this:

[patreon_access_check]

Step 2: Add this to functions.php or custom plugin:

add_shortcode('patreon_access_check', 'check_user_patron_status');
function check_user_patron_status() {
    if (!is_user_logged_in()) return '❌ Not logged in';

    if (!class_exists('Patreon_API')) return '❌ Patreon API not available';

    $user = wp_get_current_user();
    $api = new Patreon_API(get_user_meta($user->ID, 'patreon_access_token', true));
    $user_response = $api->fetch_user();

    if (isset($user_response['data']['attributes']['currently_entitled_amount_cents'])) {
        $pledge = $user_response['data']['attributes']['currently_entitled_amount_cents'];
        return ($pledge >= 50) ? '✅ Access granted' : '❌ Not enough pledge';
    }

    return '❌ Patron data missing';
}

Step 3: In your template

Use PHP to fetch that page’s content invisibly using wp_remote_get() and parse the response:

$response = wp_remote_get('https://yourdomain.com/4k-check-page/');
$body = wp_remote_retrieve_body($response);

if (strpos($body, '✅ Access granted') !== false) {
    echo do_shortcode('[elementor-template id="52248"]'); // 4K button
} else {
    echo do_shortcode('[elementor-template id="52406"]'); // Locked
}

this worked for me!