Annual patrons unable to access content

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.

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?

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

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

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

Where is $pledge variable set?

I currently check for patronage using this logic:

$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:

$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

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.

<?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;
}

?>

Nope, that’s not related to annual payments. You can get the pledge_cadence in the user’s patronage details in $user_response.

@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.

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…

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

$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;
      }  
    }
}

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.