Disable comments for non-patrons on locked Wordpress posts

Is it possible to disable comments for non-patrons on locked Wordpress posts?

Many thanks

Currently there isnt a built in feature in free or Pro plugins. But you can do that by logging into the comments_template filter. You can check for patronage of user, and then print the comments or print a message.

Yes, I was thinking to that.
How can I check for patronage for a specific post?
If the post is for a given tier only, then the same permission should apply to comments too.
How can I check the user belongs to the required tier/patronage?

checking patreon-level post meta should give you how much a post was locked for.

Patreon_Wordpress::getUserPatronage()

…should give you the user’s patronage for current user. To check for a given user instead of the current user, you can give a $user object as input.

1 Like

How can I check that the current user has enough privileges to read a given locked wordpress post?

Patreon_Wordpress::lock_or_not( $post_id );

should return an array. In that array, lock key would contain true/false result to gate the post or not, while reason key would contain the reason why the user does not qualify for access.

The plugin already maps those reasons to text strings. You can use them to make your own gated interface as well.

Thanks, it works! :slight_smile:

1 Like

This method only hides comments to the final user under a locked post (I made my own plugin).

I would like to completely hide (the content of) a comment from “recent comments” tab and comments feed (REST API too) if the user is not authorized.

Thanks in advance

Now, tab is a different matter. First you have to find where does that tab come from. Theme, a plugin, or a widget from a theme or a plugin, or something else.

Then, you can implement the same code from before to gate that tab’s content.

Brilliant! I was able to add a conditional to display the comment entry form in comments.php. Everyone can see the comments, but only patrons at a certain level are allowed to add them.

Should I add a similar check to the form handling page/routine to prevent bot submissions? If so, could you please tell me where to find it? Thank you!

That depends on your form and the plugin that handles it. A honeypot plugin that supports various form plugins may be a better choice for anti spam.

1 Like