WordPress.org

Ready to get started?Download WordPress

Forums

How to allow anonymous comments & remove fields...? (12 posts)

  1. izzy
    Member
    Posted 6 years ago #

    I've searched for this question and haven't seen anything that specifically answers my question.

    I want to have all anonymous but moderated comments and I want to have no "name" "email" "website" fields showing up at all. I want nothing but a comment box and a submit button.

    I tried removing the "input" code in comments.php and it gets rid of the fields but it also removes the message that says all comments are being held for moderation.

    I need that message to show up but it doesn't when I remove all the info related to comment author etc.

    I know cookies have something to do with it and frankly, I could care less about the cookies.

    so...can I either remove the code that creates a cookie for visitors/commenters?

    OR

    can I somehow get rid of the comment author name/email/website fields and still have the moderation message come up?

    I know there has to be a way to do this but I'm stumped.

    Thanks in advance!

  2. mrmist
    Forum Janitor
    Posted 6 years ago #

    Missing out the fields entirely would probably cause internal headaches. What you could try is altering the inputs for the fields you don't want so they they are type="hidden" with pre-defined values like "commentername" to satisfy what might be required fields in the database.

  3. izzy
    Member
    Posted 6 years ago #

    That's a great idea. I think I can do the type ="hidden". Not sure about "commentername" as my skills are not quite there yet but I will try. Any tips you have to that end are much appreciated. Thanks for your help!

  4. mrmist
    Forum Janitor
    Posted 6 years ago #

    All I was meaning there is that when you change the input types to hidden you will also need to change them so that they pass a value, so you'd have to supply that value (since you won't be asking for it in a form any more.) It'd be something like this -

    <input type="hidden" name="name" value="Anonymous"/>

  5. izzy
    Member
    Posted 6 years ago #

    Gotcha. Thank you!

  6. izzy
    Member
    Posted 6 years ago #

    I thought this was working for me but then I realized that if you use the value "anonymous" then that is the value for every post and a commenter can see all the other not yet approved posts because they all have the same author ("anonymous")

  7. mrmist
    Forum Janitor
    Posted 6 years ago #

    Hmm ok. I did not realise that it based who could see the non-approved comments on the commenter name. Are you sure that's why you can see them? (I mean, if you view the page from a different computer leaving another anonymous comment can you see all the others?)

    If that's the case, then I can only suggest randomizing the "Anonymous" value in php, so it writes "Anonymous748" or whatever.

    Changing the line to

    <?php echo '<input type="hidden" name="name" value="Anonymous';
    echo rand(100, 999);
    echo '"/> ';

    Or some more cleanly-coded version of the same would do that.

  8. izzy
    Member
    Posted 6 years ago #

    I will definitely try that. Didn't even know it was an option. Thanks!

  9. izzy
    Member
    Posted 6 years ago #

    I'm clearly challenged. I tried and couldn't get it to work.

  10. mrmist
    Forum Janitor
    Posted 6 years ago #

    What was the result?

    It may just have not worked because my syntax wasn't perfect, I didn't test it just came up with it on the spot.

  11. izzy
    Member
    Posted 6 years ago #

    I got a syntax error. I tried fiddling with it a little but I'm out of my league with PHP.

  12. dains
    Member
    Posted 6 years ago #

    Anyone still watching this? I'm working on the exact same issue. I can hide all comments via the option to moderate them.

    Then if I post a comment anonymously, I don't get the "your comment is held for moderation message". However, if I log in (as administrator), I do see the message from my previous comment.

    So, does the comment moderation message only work for users who are logged in?

Topic Closed

This topic has been closed to new replies.

About this Topic