treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Limit user to 1 comment per post

  • I am trying to figure out if there is anyway to limit users from replying more than once on a post. I've been searching for a while and so far havent found anything.



    Thanks.
  • An interesting question.

    You'd probably have to base it on IP if you do that, which could prove to be problematic and there will always be workarounds for the user.
  • What if I made all users register, then base it off of their username?
  • Interesting idea. Whats the theory behind it? Why limit to one comment?
  • Making users register is likely to put them off commenting, unless there is a point to them registering?
  • Its not to limit spam or anything, I basically want users to be able to submit an image/file/etc. and only want them to be able to do so on one post.

    so then the next day when I or the admin posts a new article the users can then again submit a reply and upload image/file/etc. only once.

    Hope I described that correctly.

    Thanks.
    Jake
  • Just wondering if anyone has got any ideas on this?


    Thanks,
    Jake
  • I think you're asking for the wrong info, Jake. I wouldn't do that with comments. Sounds like it could be an easy way to get out of programming more complicated stuff, but in the end it probably won't be. You need to develop a form for this, independent of comments. That or get a plugin. I don't know a good one that allows image uploading, though (or any, actually).

    Heh, let me know if you figure it out, though. I'd like to know how to do some of that, too.
  • he never stated, and i'm curious, is this wordpress?
  • Yes, I am using wordpress for the backend. I've found a couple of plugins that will allow uploads of images, which will work for now. But yes, I need more of a submission type of plugin that would associate with the post they replied to. I am thinking that it would be better to get a plugin or create something that would handle this.

    If anyone knows of a plugin or another way of doing this please let me know.

    Thanks for the help.
  • I saw this posted somewhere else (Your text to link here...).

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

    Maybe it's possible that it would check the post id to see if they posted, then if they didn't, then they could post.