# Annual patrons unable to access content

**URL:** <https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437>\
**Category:** Wordpress Plugin\
**Created:** [May 9, 2023, 1:52pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437 "2023-05-09T13:52:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![katiedev](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/katiedev/32/1666_2.png) [@katiedev](https://www.patreondevelopers.com/u/katiedev)\
**Post date:** [May 9, 2023, 1:52pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/1 "2023-05-09T13:52:03Z")

</div>

I’ve set up annual payments with a 16% discount. All Patreon locking is coded for my custom theme based on the Dropbox Paper documentation.

The minimum tier to access content is $5.50. With the annual discount, people are paying $4.62/ month. They are now locked out as my theme is checking for a value of $5.50.

 ![Screen Shot 2023-05-09 at 9.41.06 pm](https://canada1.discourse-cdn.com/flex036/uploads/patreondevelopers/original/2X/d/d5c9c8192d630f7dd50428ca947ada1af8ea13e3.png)

What is the best way around this? Is there an annual membership check? Or do I need to lower my locking mechanism to $4.60?

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [May 9, 2023, 11:15pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/2 "2023-05-09T23:15:38Z")

</div>

Your theme? How did you implement the pledge checking code in your theme?

---

<div class="post-metadata">

**Author:** ![katiedev](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/katiedev/32/1666_2.png) [@katiedev](https://www.patreondevelopers.com/u/katiedev)\
**Post date:** [May 10, 2023, 12:27am UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/3 "2023-05-10T00:27:57Z")

</div>

Using the same logic in your Dropbox Paper documentation.

Is there a separate check I can run for annual pledge? I saw mention of `pledge cadence` in another support post

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [May 10, 2023, 7:29pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/4 "2023-05-10T19:29:31Z")

</div>

Ah yes. Then you would manually need to account for the yearly pledges. You can check for pledge\_cadence and calculate using it:

> <https://github.com/Patreon/patreon-wordpress/blob/e5c0656b5e0631abbfa93b18ca110c7abd1aafab/classes/patreon_wordpress.php#L815>

---

<div class="post-metadata">

**Author:** ![katiedev](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/katiedev/32/1666_2.png) [@katiedev](https://www.patreondevelopers.com/u/katiedev)\
**Post date:** [May 11, 2023, 2:40pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/5 "2023-05-11T14:40:43Z")

</div>

Where is `$pledge` variable set?

I currently check for patronage using this logic:

```auto
$user_patronage = Patreon_Wordpress::getUserPatronage();
if ( $user_patronage >= 550 ) {
  // premium content
}

```

I want to check for annual patrons, and then conditionally check the pledge amount. For example:

```auto
$user_patronage = Patreon_Wordpress::getUserPatronage();

// need to get $pledge_cadence var - please assist

// set defaults
$min_pledge = 550;

// check if annual patron
if($pledge_cadence > 1) {
  $min_pledge = 462;
}

if ( $user_patronage >= $min_pledge ) {
  // premium content
}

```

Can you advise the best way to check `pledge_cadence`

---

<div class="post-metadata">

**Author:** ![katiedev](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/katiedev/32/1666_2.png) [@katiedev](https://www.patreondevelopers.com/u/katiedev)\
**Post date:** [May 14, 2023, 7:05am UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/6 "2023-05-14T07:05:51Z")

</div>

Is there a way I can cut down on this code? It seems like a lot of work to ascertain if the patron is paying annually.

```auto
<?php  
// Patreon vars
$current_user = wp_get_current_user();
$pledge = false;
$user_patronage = 0;
$min_pledge = 550;
$vip = 'no';

// Patreon queries
if(class_exists('Patreon_Wordpress')) {

	$user_response = Patreon_Wordpress::getPatreonUser( $current_user );

	$creator_id = get_option( 'patreon-creator-id', false );

	if ( is_array($user_response) && array_key_exists( 'included', $user_response ) ) {
		foreach ( $user_response['included'] as $obj ) { 
			if ( $obj["type"] == "pledge" && $obj["relationships"]["creator"]["data"]["id"] == $creator_id ) {
				$pledge = $obj;
				break;
			}  
		}
	}

	// determine user's current pledge
	$user_patronage = Patreon_Wordpress::getUserPatronage();

	// check for annual patron
	if (isset($pledge['attributes']['pledge_cadence']) AND $pledge['attributes']['pledge_cadence'] > 1) {

		// update minimum pledge amount for annual patron
		$min_pledge = 462; // 550 * 12 * 0.84 = 5544 (annual pledge = $55.44, monthly pledge = $4.62)

	}

	// Check VIP set in WordPress admin
	$vip = get_user_meta( $current_user->ID, 'cb_p6_a1_vip_user', true );
}

 // test output
 if ( $user_patronage >= $min_pledge ) {
   // premium content
   echo "you can view premium content";
   echo "<br>user patronage: " . $user_patronage;
} else {
   echo "no access";
   echo "<br>user patronage: " . $user_patronage;
}

?>

```

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [May 15, 2023, 10:21pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/7 "2023-05-15T22:21:06Z")

</div>

Nope, that’s not related to annual payments. You can get the pledge\_cadence in the user’s patronage details in $user\_response.

---

<div class="post-metadata">

**Author:** ![katiedev](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/katiedev/32/1666_2.png) [@katiedev](https://www.patreondevelopers.com/u/katiedev)\
**Post date:** [May 17, 2023, 9:44am UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/8 "2023-05-17T09:44:06Z")

</div>

@codebard i’ll switch back to $user\_patronage = Patreon\_Wordpress::getUserPatronage();` to check the pledge amount.

In the code above I’m checking the `pledge_cadence` I can verify this in testing that an annual subscriber has a cadence of 12.

Instead of a blanket “nope” can you provide some help for me.

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [May 18, 2023, 10:04pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/9 "2023-05-18T22:04:58Z")

</div>

> [@katiedev](#):
>
> `$user_response = Patreon_Wordpress::getPatreonUser( $current_user );`

You need to get the user response, and then use the pledge\_cadence in there. You can also get the user patronage easily by using get user patronage, and then divide that patronage with the cadence…

---

<div class="post-metadata">

**Author:** ![katiedev](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/katiedev/32/1666_2.png) [@katiedev](https://www.patreondevelopers.com/u/katiedev)\
**Post date:** [May 23, 2023, 3:55am UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/10 "2023-05-23T03:55:08Z")

</div>

Did you look the post I made? I already locate the `$user_response`. Everything is working in testing. However, I want confirmation that this is the most concise way to find `$pledge`

```auto
$current_user = wp_get_current_user();
$user_response = Patreon_Wordpress::getPatreonUser( $current_user );
$creator_id = get_option( 'patreon-creator-id', false );

if ( is_array($user_response) && array_key_exists( 'included', $user_response ) ) {
    foreach ( $user_response['included'] as $obj ) { 
      if ( $obj["type"] == "pledge" && $obj["relationships"]["creator"]["data"]["id"] == $creator_id ) {
        $pledge = $obj;
        break;
      }  
    }
}
```

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [May 23, 2023, 6:05pm UTC](https://www.patreondevelopers.com/t/annual-patrons-unable-to-access-content/7437/11 "2023-05-23T18:05:59Z")

</div>

Yes, thats what Im saying - get the response and combine it with the logic found in the getUserPatronage and then calculate the monthly equivalent of the yearly pledge over pledge cadence. What you posted looks ok. Just cross check it with the code in getUserPatronage.
