It seems that gifting is a new feature? Anyway, I have an API integration that relies on currently_entitled_amount_cents to distribute perks. For normal pledges this works fine, but I recently got a gifted pledge and the value is zero. Is this intended? Is there another field like currently_entitled_tiers that I’d have to use instead?
This is for the https://www.patreon.com/api/oauth2/v2/campaigns/.../members endpoint
1 Like
After experimenting with this further I can confirm that using the maximum value of currently_entitled_tiers.amount_cents
is a functional workaround.
Yes, gifting is not supported in the api at the moment but some work is underway. For now try using workarounds.
Is there any progress on this?
I have the WordPress plugin running and am testing out gift memberships. It is showing a zero pledge.
I currently use Patreon_Wordpress::getUserPatronage();
to determine the user’s pledge.
// determine user's current pledge
$user_patronage = Patreon_Wordpress::getUserPatronage();
Gifted membership support is still not implemented. If you are using the WP plugin, you could check for user’s tier from the user’s return response.
@codebard can you please supply the PHP code to do this. Thanks
This function should give you the max entitled tier $ value of the patron:
if ( isset( $pledge['attributes']['declined_since']) && !is_null( $pledge['attributes']['declined_since'] ) ) {
do_action( 'ptrn/declined_since', $pledge, $pledge['attributes']['declined_since'] );
return self::$current_user_patronage_declined = true;
}
else {
return self::$current_user_patronage_declined = false;
}
}
public static function getUserPatronageLevel( $pledge ) {
// Exception - for lite tier creators, use currently_entitled_amount_cents until there is a better way to match custom $ without tiers to local info:
if ( get_option( 'patreon-creator-has-tiers', 'yes' ) == 'no' ) {
if( isset( $pledge['attributes']['amount_cents'] ) ) {
return $pledge['attributes']['amount_cents'];
}
// Catch all from old function format
return 0;
In the same function, you can also see how you can get the exact tier.