WordPress.org

Ready to get started?Download WordPress

Forums

One Comment Per User Per Post (8 posts)

  1. sanderjansma
    Member
    Posted 3 years ago #

    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

  2. pengki
    Member
    Posted 3 years ago #

    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();
    }
    ?>
  3. daivu
    Member
    Posted 3 years ago #

    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]

  4. daivu
    Member
    Posted 3 years ago #

    this is not working boss.... can u help me

    [please don't bump]

  5. daivu
    Member
    Posted 3 years ago #

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

  6. daivu
    Member
    Posted 3 years ago #

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

  7. daivu
    Member
    Posted 3 years ago #

    ok ok its working...
    thanks

  8. daivu
    Member
    Posted 3 years ago #

    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....
    ?????

Topic Closed

This topic has been closed to new replies.

About this Topic