# \[OAuth2\] Get tier names

**URL:** https://www.patreondevelopers.com/t/oauth2-get-tier-names/10344
**Category:** Friendly Help
**Created:** [April 9, 2025, 8:36pm UTC](https://www.patreondevelopers.com/t/oauth2-get-tier-names/10344 "2025-04-09T20:36:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ScrapBlox](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/scrapblox/32/2912_2.png) [@ScrapBlox](https://www.patreondevelopers.com/u/ScrapBlox)
#### Post date: [April 9, 2025, 8:36pm UTC](https://www.patreondevelopers.com/t/oauth2-get-tier-names/10344/1 "2025-04-09T20:36:39Z")

</div>

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.

```php
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;
    }

```

---

<div class="post-metadata">

### Author: ![Greenman](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/greenman/32/2913_2.png) [@Greenman](https://www.patreondevelopers.com/u/Greenman)
#### Post date: [April 15, 2025, 10:57pm UTC](https://www.patreondevelopers.com/t/oauth2-get-tier-names/10344/2 "2025-04-15T22:57:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Greenman](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/greenman/32/2913_2.png) [@Greenman](https://www.patreondevelopers.com/u/Greenman)
#### Post date: [April 15, 2025, 11:11pm UTC](https://www.patreondevelopers.com/t/oauth2-get-tier-names/10344/3 "2025-04-15T23:11:09Z")

</div>

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:

```auto
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:

```auto
$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!

---

<div class="post-metadata">

### Author: ![noertap](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/noertap/32/2868_2.png) [@noertap](https://www.patreondevelopers.com/u/noertap)
#### Post date: [June 21, 2025, 10:27pm UTC](https://www.patreondevelopers.com/t/oauth2-get-tier-names/10344/4 "2025-06-21T22:27:40Z")

</div>


