Any dev available for a little (paid) job? Patreon / Oxygen integration

I am not sure if job requests are allowed in this forum, but I’ll give it a try.

I need a custom function to integrate the Patreon plugin in Oxygen, so I can use Oxygen conditions to show/hide elements based on the Patreon user tier.

I already ask Patron PRO dev, but he’s too busy, unfortunately.

All the specifics and contact info here

Thanks!

Any luck? I am at the same position here… Trying to solve the issue but not yet succeeded…

Yep, but I solved this differently.
Turns out using Oxygen conditions was not doable in my case.
I just asked a dev to developa piece of custom code and then I used a custom code block in Oxygen.
The custom code hide/show elements of the page depending on several conditions in my case.

Here it is, you will have to tweak it but is a good starting point.

<?php
	$tier_level_limit = 1100;
	function meditazione_restricted_content(){ ?>
		<script>
			jQuery( document ).ready(function() {
				console.log( "Confidential content!" );
				jQuery("#restricted-content" ).remove();
			});
		</script>
	<?php } ?>

	<?php
	// Code snippet for restricted users to sign up
	function meditazione_sign_up(){ ?>
		[code_snippet id=38 php=true shortcodes=true]
	<?php } ?>

	<?php
	// Check post type
	if ( get_post_type( get_the_ID() ) == 'meditazione' ) {
		// Check if the current lesson is free or requires access
		$free_meditation = get_field( "free_meditation" );
		if( $free_meditation ){
			// echo "Free Lesson";
		} else {

			if ( is_user_logged_in() ) {
				$user = wp_get_current_user();
				$user_patronage = Patreon_Wordpress::getUserPatronage();
				$declined = Patreon_Wordpress::checkDeclinedPatronage($user);
				$vip = 'no';
				$vip = get_user_meta( $user->ID, 'cb_p6_a1_vip_user', true );
				$user_patreon_level = get_user_meta( $user->ID, 'cb_p6_a1_patreon_level', true );
				global $wp;
				$redir = home_url(add_query_arg($_GET,$wp->request));
				if( $vip ){
					// echo "vip <br>";
				} else {
					// echo "No vip <br>";

					// Check user's Patreon level
					if ( ( ! $declined ) OR !current_user_can( 'manage_options' ) ) {
						if ( $user_patronage >= $tier_level_limit ){
							// echo '$user_patronage: ' . $user_patronage .' > 21<br>';
						} elseif( $user_patreon_level >= $tier_level_limit ) {
							// echo '$user_patreon_level: ' . $user_patreon_level .' > 21<br>';
						} else {
							meditazione_restricted_content();
							meditazione_sign_up();
						}
					}
				}
			} else {
				meditazione_restricted_content();
				meditazione_sign_up();
			}
		}
	}
?>

The shortcode [code_snippet id=38 php=true shortcodes=true]
is what is showed to users that have not access to the content, you can change this with the custom Patron PRO banner plugin if you want.

Thanks Kyrian i was able to solve it in the weekend. I created a custom pfp function that returns true and false if a user is a member of a tier ornot according to tier id. Actually i was gonna send it to you but you also solved it…

I just only can add to your reply is the key is:

Class that is being created with patreon plugin.

Thanks for sending the code

and heres what i did…

function patreon( $desired_tier_id ) {
	
$current_user = wp_get_current_user();
$patreon_user = Patreon_Wordpress::getPatreonUser($current_user);

// Check if the user is a member of a specific tier
//$desired_tier_id = '9665673'; // replace with the ID of the tier you want to check
$is_member_of_tier = false;

if(isset($patreon_user['included'])) {
    foreach ($patreon_user['included'] as $included_item) {
        if ($included_item['type'] === 'pledge') {
            if (isset($included_item['relationships']['currently_entitled_tiers']['data'])) {
                foreach ($included_item['relationships']['currently_entitled_tiers']['data'] as $tier) {
                    if ($tier['id'] === $desired_tier_id) {
                        $is_member_of_tier = true;
                        break 2;
                    }
                }
            }
        }
    }
}

if($is_member_of_tier) {
	$ret=true;
} else {
	$ret=false;
}
	return $ret;
	
}

thanks for sharing this!

1 Like