• Resolved glinch

    (@glinch)


    Hi all,

    Ive been searching for days now for a how to/plugin that will restrict only users of any role to be able to leave/view comments to posts. People that arent registered cant leave comments.

    The story behind this is that the site is for a sports team. I would like the match reports to be freely available to all who wish to view them. I would however like the players/registered user to only be able to comment or discuss the match report.

    Any help would be greatly appreciated.

    Cheers
    Noel

Viewing 2 replies - 1 through 2 (of 2 total)
  • So you only want registered viewers to even see comments then?

    That’s pretty simple – you need to check to see if the end user is logged in, and if so, then show the comments. If not, then they just see the post.

    Put this in your single.php file:

    if (current_user_can('level_0')) {
    comments_template();
    }

    The above checks to see if the end user is logged on (“0” being a subscriber), and if they are, then it’ll display the comments and the form to leave one. If the end user *isn’t* logged in, they won’t see anything.

    You should know that some spammers simply know that the comments.php file exists, and they use automated methods to connect you that file and leave comments without being on the site. So it’s possible you’ll still get some comments bleeding through that you don’t want. To alleviate this, be sure you have your Akismet/Bad Behavior (or whatever secondary anti-spam plugin you want to use) in place, and at the very least set yourself to be notified when a comment is left on the site – then if it is a spammer that got through, you can go delete it.

    Thread Starter glinch

    (@glinch)

    Thats fantastic doodlebee, thanks alot for your help really appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to restrict who can view comments’ is closed to new replies.