# PHP - how to check if content is locked?

**URL:** <https://www.patreondevelopers.com/t/php-how-to-check-if-content-is-locked/3508>\
**Category:** Wordpress Plugin\
**Created:** [August 5, 2020, 12:47pm UTC](https://www.patreondevelopers.com/t/php-how-to-check-if-content-is-locked/3508 "2020-08-05T12:47:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Rodenbroker](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/tim_rodenbroker/32/1401_2.png) [@Tim\_Rodenbroker](https://www.patreondevelopers.com/u/Tim_Rodenbroker)\
**Post date:** [August 5, 2020, 12:47pm UTC](https://www.patreondevelopers.com/t/php-how-to-check-if-content-is-locked/3508/1 "2020-08-05T12:47:22Z")

</div>

Hi everyone, i am using the Wordpress-plugin and instead of just locking “the\_content” and displaying the “unlock with patreon”-badge, i would like to forward the visitor to a specific page.

So my question is:

How can i check if the content on a specific page is locked?

Thanks!!!

---

<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:** [August 5, 2020, 10:51pm UTC](https://www.patreondevelopers.com/t/php-how-to-check-if-content-is-locked/3508/2 "2020-08-05T22:51:14Z")

</div>

patreon-level meta attached to any post/page/custom post carries the lock value. If its anything more than 0, then the specific page is locked.

Using that meta and hooking into the link generating function for pledge flow link that is used in post interface, you can construct your own links and pass it to the interface to be used instead of the original link.

---

<div class="post-metadata">

**Author:** ![Tim\_Rodenbroker](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/tim_rodenbroker/32/1401_2.png) [@Tim\_Rodenbroker](https://www.patreondevelopers.com/u/Tim_Rodenbroker)\
**Post date:** [August 6, 2020, 5:48am UTC](https://www.patreondevelopers.com/t/php-how-to-check-if-content-is-locked/3508/3 "2020-08-06T05:48:26Z")

</div>

Oh, that’s awesome. Thank you very much !!!

---

<div class="post-metadata">

**Author:** ![Tim\_Rodenbroker](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/tim_rodenbroker/32/1401_2.png) [@Tim\_Rodenbroker](https://www.patreondevelopers.com/u/Tim_Rodenbroker)\
**Post date:** [August 6, 2020, 7:36am UTC](https://www.patreondevelopers.com/t/php-how-to-check-if-content-is-locked/3508/4 "2020-08-06T07:36:29Z")

</div>

Hi @codebard, i have one more question:

You have said that the “patreon-level meta” carries the pledge level. Could you explain shortly how to retrieve this value in PHP?

Thanks in advance!

---

<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:** [August 6, 2020, 7:38pm UTC](https://www.patreondevelopers.com/t/php-how-to-check-if-content-is-locked/3508/5 "2020-08-06T19:38:55Z")

</div>

Just the normal WP way:

$patreon\_level = get\_post\_meta( $post-\>ID, ‘patreon-level’, true );

$post is the $post object. You can feed $post-\>ID either via the post object in the example, or you can just feed an integer post id id.
