Learn in this tutorial how to restrict viewing and adding comments only for active Restrict Content Pro subscribers in a block theme.
But block themes are already a reality and they are going to be used more and more, so in this tutorial you are going to see how you can achieve the same but using a new generation theme.

Here is the code you need:
Instructions for hiding comments from users who do not have an active RCP subscription
1. Create a snippet that limits comments
Add the following code snippet to your functionality plugin:
To see this and another 965 code snippets of this website, login or subscribe here.
In this code you use the rcp_user_has_active_membership
function to check if the user has an active subscription and the render_block
filter to display a message in case the reader does not meet the condition.
In addition, you take advantage of the message or CTA in the hidden area so that non-subscribers understand why they do not see the comments and invite them to subscribe or identify themselves.
You can modify both the text displayed and the URL where to register (changing /register/ for the slug where your registration page is).
The above code would apply to all posts with comments, but if you are interested in limiting it to normal posts (blog articles) or some Custom Post Type
in particular, you would have to add a conditional tag to make it so. For example:
To see this and another 965 code snippets of this website, login or subscribe here.
In this case, by using is_singular('course')
you get the message to be displayed only in the course CPT entries. Just replace it with the CPT you are interested in.
Finally, if you are using a plugin that displays a modal window to speed up user login, you must also modify the above code. This would be the code to integrate it with Osom Modal Login:
To see this and another 965 code snippets of this website, login or subscribe here.
In this case, clicking on the text “login” will open a modal window to enter the user name and password.
2. Customize the CTA CSS in the comments area
Once you have hidden the comments from non-subscribers, you just need to give a little style to the message that appears in the restricted area.
To do this, add this block to the end of style.css:
To see this and another 965 code snippets of this website, login or subscribe here.
By inserting these CSS lines you ensure that the message is displayed respecting the Twenty Twenty-Three theme styles.

In this case, for the links you use the secondary color since the primary is a very light green that doesn’t have enough contrast with the white background. But if in the theme you are using the combination has good contrast you could use the primary color. This would be the code:
.rcp-restricted a {
color: var(--wp--preset--color--primary);
}
You can also add colors using hex code or font size with pixels and/or rem, but I recommend you get used to using CSS variables.
I also invite you to finish customizing the design to your liking. 😉
Conclusions
Now you know how to hide comments to non-subscribers on one or several post types in your block theme, and add a custom message inviting them to register or login.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉