PHP - how to check if content is locked?

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!!!

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.

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

1 Like

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!

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.