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

**URL:** <https://www.patreondevelopers.com/t/any-dev-available-for-a-little-paid-job-patreon-oxygen-integration/7034>\
**Category:** Friendly Help\
**Created:** [February 15, 2023, 5:06pm UTC](https://www.patreondevelopers.com/t/any-dev-available-for-a-little-paid-job-patreon-oxygen-integration/7034 "2023-02-15T17:06:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyrian](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/kyrian/32/2212_2.png) [@Kyrian](https://www.patreondevelopers.com/u/Kyrian)\
**Post date:** [February 15, 2023, 5:06pm UTC](https://www.patreondevelopers.com/t/any-dev-available-for-a-little-paid-job-patreon-oxygen-integration/7034/1 "2023-02-15T17:06:07Z")

</div>

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](https://kyriannairyk.notion.site/Patreon-Oxygen-Integration-dev-forum-b93131c726c44784a8cde5b08498878c)

Thanks!

---

<div class="post-metadata">

**Author:** ![Kutluhan\_Aykut](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/kutluhan_aykut/32/2306_2.png) [@Kutluhan\_Aykut](https://www.patreondevelopers.com/u/Kutluhan_Aykut)\
**Post date:** [April 2, 2023, 4:58am UTC](https://www.patreondevelopers.com/t/any-dev-available-for-a-little-paid-job-patreon-oxygen-integration/7034/2 "2023-04-02T04:58:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kyrian](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/kyrian/32/2212_2.png) [@Kyrian](https://www.patreondevelopers.com/u/Kyrian)\
**Post date:** [April 3, 2023, 8:20am UTC](https://www.patreondevelopers.com/t/any-dev-available-for-a-little-paid-job-patreon-oxygen-integration/7034/3 "2023-04-03T08:20:10Z")

</div>

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.

```auto
<?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.

---

<div class="post-metadata">

**Author:** ![Kutluhan\_Aykut](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/kutluhan_aykut/32/2306_2.png) [@Kutluhan\_Aykut](https://www.patreondevelopers.com/u/Kutluhan_Aykut)\
**Post date:** [April 3, 2023, 8:43am UTC](https://www.patreondevelopers.com/t/any-dev-available-for-a-little-paid-job-patreon-oxygen-integration/7034/4 "2023-04-03T08:43:12Z")

</div>

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:

> [@Kyrian](#):
>
> `Patreon_Wordpress`

Class that is being created with patreon plugin.

Thanks for sending the code

and heres what i did…

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

```

---

<div class="post-metadata">

**Author:** ![Kyrian](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/kyrian/32/2212_2.png) [@Kyrian](https://www.patreondevelopers.com/u/Kyrian)\
**Post date:** [April 3, 2023, 8:57am UTC](https://www.patreondevelopers.com/t/any-dev-available-for-a-little-paid-job-patreon-oxygen-integration/7034/5 "2023-04-03T08:57:54Z")

</div>

thanks for sharing this!
