# Patron PRO plugin not respectin tiers? (code recipe)

**URL:** <https://www.patreondevelopers.com/t/patron-pro-plugin-not-respectin-tiers-code-recipe/7116>\
**Category:** Wordpress Plugin\
**Created:** [March 2, 2023, 1:09pm UTC](https://www.patreondevelopers.com/t/patron-pro-plugin-not-respectin-tiers-code-recipe/7116 "2023-03-02T13:09:25Z")\
**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:** [March 2, 2023, 1:09pm UTC](https://www.patreondevelopers.com/t/patron-pro-plugin-not-respectin-tiers-code-recipe/7116/1 "2023-03-02T13:09:25Z")

</div>

Hello,  
A dev I am working with implemented this code recipe

[https://www.dropbox.com/scl/fi/69dejrx1ol95tx5kvww78/Patron-Pro-how-to-lock-any-part-of-your-Website.paper?dl=0&rlkey=knv5utdczkmlzm68lmjm7p46v](https://www.dropbox.com/scl/fi/69dejrx1ol95tx5kvww78/Patron-Pro-how-to-lock-any-part-of-your-Website.paper?dl=0&rlkey=knv5utdczkmlzm68lmjm7p46v)

to restrict access depending on the Patreon tier to elements outside of default WP fields

But after testing I noticed that the code provides access to all Patreon subscribers, no matter what tier they have (in the below Code they should have a tier \> 21 to get access).

Any idea what is wrong? Thanks for any heads up 🙂

Here is the full code

```auto
<?php
    function lezione_restricted_content(){ ?>
        <script>
            jQuery( document ).ready(function() {
                console.log( "Confidential content!" );
                jQuery("#restricted-content" ).remove();
            });
        </script>
<?php } ?>
<?php
    function lezione_sign_up(){ ?>
        <div class="well-blue restricted-content">
            Restricted content
        </div>
<?php } ?>

<?php
	if ( get_post_type( get_the_ID() ) == 'lezione' ) {
		$free_lesson = get_field( "free_lesson" );
		if( $free_lesson ){
			// echo "Free Lesson";
		} else {

			if ( is_user_logged_in() ) {
				if ( !$user ) {
					$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 );
				$redir = home_url(add_query_arg($_GET,$wp->request));
				if( $vip ){
					// echo "vip <br>";
				} else {
					// echo "No vip <br>";
					$user_roles = ( array ) $user->roles;	
					$terms = get_the_terms( get_the_ID(), 'corso' ); 

                    if($terms){
                        foreach($terms as $term) {
                            $slug = $term->slug;
                            if ( in_array( $slug, $user_roles ) ) {
                                // echo 'what have a match!<br>';
                                // echo $slug .'<br>';
                            } else {
                                // echo 'NO match!<br>';
                                // echo $slug .'<br>';

                                // echo '$user_patronage: ' . $user_patronage .'<br>';
                                // echo '$user_patreon_level: ' . $user_patreon_level .'<br>';
                                if ( ( ! $declined ) OR !current_user_can( 'manage_options' ) ) {
                                    if ( $user_patronage > 21 ){
                                        // echo '$user_patronage: ' . $user_patronage .' > 21<br>';
                                    } elseif( $user_patreon_level > 21 ) {
                                        // echo '$user_patreon_level: ' . $user_patreon_level .' > 21<br>';
                                    } else {
                                        lezione_restricted_content();
                                        lezione_sign_up();
                                    }
                                }
                            }
                        }
                    } else { 
                        lezione_restricted_content();
                        lezione_sign_up();
                    }
				}
			} else {
                lezione_restricted_content();
                lezione_sign_up();
			}
		}
	}
?>

```

---

<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:** [March 2, 2023, 3:52pm UTC](https://www.patreondevelopers.com/t/patron-pro-plugin-not-respectin-tiers-code-recipe/7116/2 "2023-03-02T15:52:04Z")

</div>

No need to check for $declined.

That code is working on many websites at this moment. Its likely that there may be a situation at your site, or your site may have lost connection to Patreon because your creator access token got refreshed. That currently happens if you try to log in to your site with your creator account. Try checking if your site was disconnected and reconnecting it.

---

<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:** [March 2, 2023, 5:04pm UTC](https://www.patreondevelopers.com/t/patron-pro-plugin-not-respectin-tiers-code-recipe/7116/3 "2023-03-02T17:04:26Z")

</div>

I think the site is connected to Patreon because the code works for providing access only to Patreon subscribers, the issue is that it doesn’t respect the tier that is set in the code,

```auto
                                    if ( $user_patronage > 21 ){
                                        // echo '$user_patronage: ' . $user_patronage .' > 21<br>';
                                    } elseif( $user_patreon_level > 21 ) {
                                        // echo '$user_patreon_level: ' . $user_patreon_level .' > 21<br>';
                                    } else {

```

it provides access to all Patreon subscribers.

---

<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:** [March 7, 2023, 9:11pm UTC](https://www.patreondevelopers.com/t/patron-pro-plugin-not-respectin-tiers-code-recipe/7116/4 "2023-03-07T21:11:02Z")

</div>

A fix for this kind of tier mismatching went out at [patreon.com](http://patreon.com) very recently. Give a try to testing it out again.

---

<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:** [March 8, 2023, 9:01am UTC](https://www.patreondevelopers.com/t/patron-pro-plugin-not-respectin-tiers-code-recipe/7116/5 "2023-03-08T09:01:01Z")

</div>

Actually, it turns out the error was in my code. Patreon tier needs to be written with 2 zeros as decimals, like 1100, and not 11.

Thanks
