WordPress.org

Support

Support » How-To and Troubleshooting » One Comment Per User Per Post

One Comment Per User Per Post

  • sanderjansma
    Member

    @sanderjansma

    Hello *,

    I am looking for a way to implement the following in a website:
    Only registered members can post comments on posts (basic functionality ofcourse), but each member can only comment once per post.

    Is there a way to do this?

    Cheerio!

    Sander

Viewing 7 replies - 1 through 7 (of 7 total)
  • Simple approach is to check whether a user has commented the post, or not. If they have commented the post, then disable comment form.

    This can be done by editing comments.php file in your active theme.

    <?php
    global $current_user;
    $args = array('user_id' => $current_user->ID);
    $usercomment = get_comments($args);
    if(count($usercomment) >= 1){
    	echo 'disabled';
    } else {
    	comment_form();
    }
    ?>

    i have a big problem related to this post…
    pengki please help……

    i m also need one comment one one post….. but where i have to put the code… so its make working….

    please help soon ..

    thanks

    i have paste code…
    waiting for ur reply…

    [code moderated per forum rules – please use the pastebin]

    this is not working boss…. can u help me

    [please don’t bump]

    its showing disable but form is working… can i disable form….

    its working nice but i did not adjust form function….

    ok ok its working…
    thanks

    ok boss its working… but next time the form not showing for next post…… one user can one post in all project as this code doing… but i need 1 comment on one post…by 1 user… but not to restrict for other post….
    ?????

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘One Comment Per User Per Post’ is closed to new replies.