Support » Plugin: Paid Memberships Pro » Display Comments only for Members

  • Resolved marianitx

    (@marianitx)


    Hi,

    I just created a website with your plugin and everything is working fine so far.

    I wonder whether there is any way to display the coments section for each post ONLY for members. There are some posts that will be open for everyone, but I want in those, the coments section to be displayed only for subscriptors, because is one of the advantages that we created for them (to coment in entries and some pages).

    Looking forward to hear from you back.

    Best wishes for 2021

    María

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Kim White

    (@kimwhite)

    Hello and Happy New Year.

    We do not have a setting that would hide comments by level.

    If it’s a general, anyone with an account, you could do something like this:
    https://wordpress.stackexchange.com/questions/96406/how-do-i-hide-all-comments-from-logged-out-users

    Please let us know if this works for you.

    Kim W

    Thread Starter marianitx

    (@marianitx)

    Hi Kim, thanks for your answer.

    Actually, sounds great, this solution would do the trick, at least for the moment. I was following instructions and pasting the code in my coments.php file at the very top, but unfortunately I got a sintax error and the page got broken. I’m not sure what I did wrong, cause I just copy and pasted exactly this:

    <?php
    if (!is_user_logged_in()) {
        return;
    }

    Any hint?

    Regards,

    María

    Plugin Support Kim White

    (@kimwhite)

    This code needs to be put in its own plugin. You don’t want to alter theme files or WordPress files.
    https://gist.github.com/kimwhite/c14bb79a0f3d19cbf9314f883a7473ed

    Kim W

    Thread Starter marianitx

    (@marianitx)

    Hi Kim,
    I just installed Code Snippet plugin, created a new snippet and pasted this code:

    <?php
    if (!is_user_logged_in()) {
        return;
    }

    I marked “Run everywhere”, but no changes are being displayed at all. Coments are still being visualized for non logged users.

    Any clue what am I doing wrong?

    Thanks again,

    María

    Plugin Author Andrew Lima

    (@andrewza)

    Hi Maria,

    Could you please ensure you have the entire code snippet as per Kim’s example.

    If you need further assistance with this, I recommend reaching out to a local WordPress developer to assist you.

    Here is an article that also has an example of disabling ‘comments_array’ filter – https://www.paidmembershipspro.com/display-comments-of-a-member-only-blog-post-to-non-members/

    Thank you for understanding.

    Thread Starter marianitx

    (@marianitx)

    Hi Andrew, thanks for your answer.
    Unfortunately I cannot open the link you are providing, as it is only visible for plus members.

    I created a new snippet and copied and pasted exactly same code that Kim provided. Take a look at this screenshot:

    https://drive.google.com/file/d/1rPeSFcyHEoea-bQRF5bm9nZgigV8wYt1/view?usp=sharing

    What am I doing wrong? When it says “if functions exists” do I have to create that function?

    Thanks in advance,

    María

    Plugin Author Andrew Lima

    (@andrewza)

    Thanks for the feedback María, please note that our support doesn’t cover troubleshooting of custom code snippets and we usually recommend reaching out to a local WordPress developer to get this fixed/implemented.

    If the code shared does not work, something else may be interfering with your comment section or loading it as a ‘priority’.

    Here is the code snippet that should work for you (from the guide previously shared) – https://gist.github.com/travislima/e2a8ec1eae51c8014de20e1e99b67456#file-pmpro-open-comments-non-members-php

    Thank you for understanding.

    Thread Starter marianitx

    (@marianitx)

    Hi Andrew,
    thanks for your quick answer. I understand what you mean, and I will do what you suggest if I’m not able to implement it my self. The only thing is that,in this post thread, I was provided with more than one code snippetand I got a bit confused. This is why, I think, the reason is not working is because I did not get yet the right code to paste. Actually, the link you just provided is for exactly the opposite to what I need: I need comments to be removed for non registered users.

    Thanks again!!

    María

    Thread Starter marianitx

    (@marianitx)

    I am trying with this code:

    <?php
    
    if ( ! function_exists( 'see_comments_after_login' ) )
    {
        add_filter( 'comments_template', 'see_comments_after_login', 11 );
    
        function see_comments_after_login( $comments_template )
        {
            return is_user_logged_in() ? $comments_template : __FILE__;
        }
    }

    Should I paste it like it is here? or do I have to substitute any part of the code like “__FILE__”??

    Thanks again,

    María

    Plugin Author Andrew Lima

    (@andrewza)

    Thanks for the feedback María. I have tested this code on my site and it works as intended (I used the default TwentyTwentyOne theme).

    It may not be working due to your theme or another plugin that may hook in on or not use the ‘comments_template’ WordPress hook.

    I recommend in reaching out to a local WordPress developer as this issue is site specific and with generalized WordPress functionality.

    Thank you for understanding.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.