# Hardcoding category protection

**URL:** <https://www.patreondevelopers.com/t/hardcoding-category-protection/953>\
**Category:** Wordpress Plugin\
**Created:** [July 25, 2018, 10:27am UTC](https://www.patreondevelopers.com/t/hardcoding-category-protection/953 "2018-07-25T10:27:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewwwinter](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@matthewwwinter](https://www.patreondevelopers.com/u/matthewwwinter)\
**Post date:** [July 25, 2018, 10:27am UTC](https://www.patreondevelopers.com/t/hardcoding-category-protection/953/1 "2018-07-25T10:27:17Z")

</div>

Was previously using Memberful, but looking at moving over to Patreon. However, I had hardcoded the protection of three categories on Wordpress for three different membership tiers. Now I’m wanting to do that with Patreon pledges. My hardcoding for Memberful in my single.php file was:

_\<?php if ( has\_category( array('plus', 'elite', 'gold')) && ! is\_subscribed\_to\_memberful\_plan ( array('15656-ennui-plus', '19593-ennui-plus-gold', '27417-ennui-plus-elite' ) ) ) { ?\>_

_\<?php the\_post\_thumbnail(); ?\>_

_You can watch this content if you’re an [Ennui Plus](https://ennuitv.memberful.com/checkout?plan=15656) member, or a member on the [Ennui Plus Gold](https://ennuitv.memberful.com/checkout?plan=19593) or [Ennui Plus Elite](https://ennuitv.memberful.com/checkout?plan=27417) levels. Become a member now to get early access, exclusive content and more!_

Is there a way to do this with Patreon?

---

<div class="post-metadata">

**Author:** ![AhmadShahzad](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/ahmadshahzad/32/607_2.png) [@AhmadShahzad](https://www.patreondevelopers.com/u/AhmadShahzad)\
**Post date:** [July 25, 2018, 5:16pm UTC](https://www.patreondevelopers.com/t/hardcoding-category-protection/953/2 "2018-07-25T17:16:00Z")

</div>

When you use the Patreon Plugin, you get the option to lock posts according to Tiers

Ennui Plus Tier - 10$ or whatever amount  
Ennui Plus Gold Tier - 20$ or whatever amount  
Ennui Plus Elite Tier - 30$ or whatever amount

Basically, you can lock your posts according to Tiers, so only people who pledge that amount will be able to see that post.

---

<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:** [July 25, 2018, 7:26pm UTC](https://www.patreondevelopers.com/t/hardcoding-category-protection/953/3 "2018-07-25T19:26:45Z")

</div>

Yes that can be done with that level of code modification, rather easily:

Patreon\_Wordpress::getUserPatronage();

…will give you the pledge level of the current logged in patron. You can use this to custom-check for anything:

if(Patreon\_Wordpress::getUserPatronage()\>5) {

}

… for example, will allow you to check if a patron has higher than $5. You can use it anywhere.

---

<div class="post-metadata">

**Author:** ![matthewwwinter](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@matthewwwinter](https://www.patreondevelopers.com/u/matthewwwinter)\
**Post date:** [July 30, 2018, 11:27pm UTC](https://www.patreondevelopers.com/t/hardcoding-category-protection/953/4 "2018-07-30T23:27:28Z")

</div>

What would I be putting in my functions.php to create the function first, though?

I roughly know what to put in my single.php by adapting my Memberful one I made and the code you gave me.

---

<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:** [July 30, 2018, 11:35pm UTC](https://www.patreondevelopers.com/t/hardcoding-category-protection/953/5 "2018-07-30T23:35:25Z")

</div>

Not in single.php, but in category related templates. A quick google search can show you how to access these templates. Then you can wrap the listing loop in if’s.
