WordPress.org

Ready to get started?Download WordPress

Forums

Hack: only registered users can post comments (28 posts)

  1. designbymichael
    Member
    Posted 10 years ago #

    Oh, and on a different note... it'd be nice if the thing actually worked and preserved all formatting between the code tags. If my instructions seemed illegible, you can find them here...
    http://www.michaeltangen.com/comments_hack.txt

  2. OperaManiac
    Member
    Posted 10 years ago #

    its not code tag u use. u use backticks... the key on left of 1 key...

  3. designbymichael
    Member
    Posted 10 years ago #

    gotcha. didn't see the obvious right above the textarea. thnx.

  4. Anonymous
    Unregistered
    Posted 10 years ago #

    Have tried this. works great! Thanks!

  5. Ruby Sinreich
    Member
    Posted 10 years ago #

    Very cool. I may use this if I can't get the commenters to behave...
    Thanks!

  6. Ruby Sinreich
    Member
    Posted 10 years ago #

    Question 1: is there any way to require a valid e-mail address when folks register? I guess this would involve sending a welcome message to the address with a link to validate it. if I can't force them to use a real e-mail address, this won't be nearly as helpful.
    Question 2: can I use this plugin to control the level of the user? (eg: only users level 3 and above can post comments.)

  7. davejay
    Member
    Posted 10 years ago #

    Quick comment: use the code version Michael's linked to (the txt file on his site) rather than the code in here -- it doesn't work right. On the other hand, the code on his site works beautifully. Thanks, Michael!

  8. banjolawyer
    Member
    Posted 10 years ago #

    I got the following error after adding this code.. Any ideas about what would cause it?
    Parse error: parse error in /home/johnlitt/public_html/blog/wp-comments.php on line 8
    The line that is the problem is
    if ((empty($user_nickname))&&(empty($user_email))) {

  9. banjolawyer
    Member
    Posted 10 years ago #

    oops should have read the last post.. will try the linked code.

  10. banjolawyer
    Member
    Posted 10 years ago #

    that did the trick.

  11. kurakin
    Member
    Posted 9 years ago #

    Made some small changes so that the comment form isn't even shown unless the user is logged in. After the line:
    <?php if ('open' == $post->comment_status) { ?>
    add:
    <?php if (isset ($message)) {
    ######### comments hack by Jamison & Michael
    echo $message; // display message if they're not logged in
    }
    else {
    ?>

    and change the line
    <?php } else { // comments are closed ?>
    to be
    <?php }} else { // comments are closed ?>
    Then they can't even use any little tricks to bypass the disabled form stuff. (I have a plugin for firefox that will do exactly that, and it wouldn't be hard to remove them with a regex in a spam script)

  12. Anonymous
    Unregistered
    Posted 9 years ago #

    The last code posted doesn't seem to work. The forms are still there!

  13. Anonymous
    Unregistered
    Posted 9 years ago #

    I tried it and had the same results. The comment form still appears.

  14. Anonymous
    Unregistered
    Posted 9 years ago #

    Although well-written and -executed, this hack did not stop the "texas holdem" attack. I will try other methods...

  15. EddieDee
    Member
    Posted 9 years ago #

    Well, the forums really screwed up the code in my last post. So if you want the code to make the changes to the forum, and can't figure it out because of the stupidity of the forums translation, email me and I'll send it to you.
    Eddie

  16. emma2
    Member
    Posted 9 years ago #

    Excellent, and I thank you, but the casino spammers have broken through. Who knows how...it's a mystery.
    Back to the drawing board.
    (My first post to the forum; hi, all!)

  17. Anonymous
    Unregistered
    Posted 9 years ago #

    Its because you are only blocking the posting form, not what processes it. Add this to the wp-comments-post.php file, after the test for required_name_email.
    # Require user to be registered and logged in before allowing posting
    # 30 second hack by Brian C. Lane - www.libertynews.org
    get_currentuserinfo();
    if( empty($user_nickname) && empty($user_email) )
    die( __('Error: You must be logged in before you can post') );

  18. Anonymous
    Unregistered
    Posted 9 years ago #

    Ugh, pretty ugly. You should get the gist of it though, call get_currentuserinfo() and then see if nickname and email are empty.

  19. Anonymous
    Unregistered
    Posted 9 years ago #

    You can also add similar code to wp-comments.php to totally remove the form:
    # Require user to be registered and logged in before allowing posting
    # 30 second hack by Brian C. Lane - www.libertynews.org
    get_currentuserinfo();
    if( empty($user_nickname) && empty($user_email) )
    _e("Sorry, you must login before posting.");
    else if ('open' == $post->comment_status) {

  20. Anonymous
    Unregistered
    Posted 9 years ago #

    appreciate it guys - i just started getting attacked by the dreaded web-casino bots..far out they can be annoying.

  21. abi
    Member
    Posted 9 years ago #

    thanks for this - works beautifully :-)

  22. Jennifer Ledbetter Clay
    Member
    Posted 9 years ago #

    I am having a problem with this hack...

    Hack works great, but I cannot seem to stay logged in... any suggestions?

  23. Meursault
    Member
    Posted 9 years ago #

    So...I added the 30 second hack by Brian C Lane and nothing happened. It says "sorry, you must be logged in before posting", but still allows you to post comments.

  24. kadazuro
    Member
    Posted 9 years ago #

    also you can add a redirect url, so when de users logs in is redirected to de original page.
    [code]
    # Require user to be registered and logged in before allowing posting
    # 30 second hack by Brian C. Lane - http://www.libertynews.org
    get_currentuserinfo();
    if( empty($user_nickname) && empty($user_email) )
    _e('Sorry, you must login before posting.');
    else if ('open' == $post->comment_status) {
    [/code]

    btw i add this around line 74 and works great ;)

  25. kadazuro
    Member
    Posted 9 years ago #

    fixed again xD
    this time set de vars the form espect to, so it hides de form and shows de welcome back

    # Require user to be registered and logged in before allowing posting
    # 30 second hack by Brian C. Lane - www.libertynews.org
    get_currentuserinfo();
    if( empty($user_nickname) && empty($user_email) )
    _e('Sorry, you must login before posting.');
    else if ('open' == $post->comment_status) {
    $comment_author_email = $user_email;
    $comment_author = $user_nickname;

    kada
    shouting in the dark.

  26. Meursault
    Member
    Posted 9 years ago #

    Hm...what do you think I'm doing wrong? I get the message but can still post comments while logged out.

  27. Meursault
    Member
    Posted 9 years ago #

    Ahh...I think I had it in the wrong place. Thanks.

  28. syncbox
    Member
    Posted 8 years ago #

    Hi,
    Designbymichael, your file says:
    Open up the wp-comments.php file and add these few lines of code after the opening <?php tag

    where is that wp-comments.php file? within WordPress? I can't find one.

    I am new at WP, so patience is appreciated. I'm trying to require a user to be registered and logged in to comment.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.