WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Comment Leader Hack (40 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    Not real familiar with WP yet, so alert me of any problems.
    Download
    wp_comment_leaders
    Tag
    <?php get_comment_leaders(); ?>
    Arguments Definition:

    1. A number that limits the amount of records that are to be shown. (default's '5')
    2. A string that excludes certain names from appearing in the list. Separate multiple names with a comma.
    3. A number: pads the visitor's total comment count with zeros.
    4. A string to display before the record.
    5. A string to display after the record. (default is a line break '
      ')
    6. Example
      <?php get_comment_leaders( 10, "admin_name, spammer_name", 3, '

    7. ', '
    8. '); ?>

  2. Orbit Juice
    Member
    Posted 10 years ago #

    Sweet script. Good work.
    I tweaked it a little to the output format I wanted.
    You can see it here: http://www.orbitjuice.com

  3. Orbit Juice
    Member
    Posted 10 years ago #

    Also... I edited the code for multiple and single comments.
    i.e.:
    Eric left 15 comments
    Will left 8 comments
    John left 2 comments
    Mary left 1 comment

  4. Anonymous
    Unregistered
    Posted 10 years ago #

    thanks :)

  5. Anonymous
    Unregistered
    Posted 10 years ago #

    Yea I liked what you did so I changed it to look similar to yours... also made it so that it recognizes single and multiple, comments.also. Thanks

    1. A number that limits the amount of records that are to be shown. (default's '5')
    2. A string that excludes certain names from appearing in the list. Separate multiple names with a comma.
    3. A string to display before the record.
    4. A string to display between the record. (default "-")
    5. A string to display after the record. (default is a line break '
      ')

    Example
    <?php get_comment_leaders( 10, "admin_name, spammer_name", '

  6. ', 'posted', '
  7. '); ?>

  • Orbit Juice
    Member
    Posted 10 years ago #

    Here is mine. It's a little different. It changes on the output.
    if ($author_comment_count != 1) {
    echo "$before$comment_author_link - $author_comment_count comments$after";
    } else {
    echo "$before$comment_author_link - $author_comment_count comment$after"; }

  • southerngal
    Member
    Posted 10 years ago #

    Thanks for this...another thing to play with. ;)

  • Daisyhead
    Member
    Posted 10 years ago #

    I love this hack. I would like to make som modifications to it, but I'm unsure how. I'd like my output to look like this:
    Jess - 184 total
    last commented: (date of last comment)
    on entry: (entry title last commented on w/link to entry)
    Is there a way to do this?

  • Nick Momrik
    Member
    Posted 10 years ago #

    The portion of the function that figures the last comment by an author doesn't work. I was going to try to fix the query, but it's not an easy one.

  • Hamoudy
    Member
    Posted 10 years ago #

    Yeah I was having the same problem too. With the "Last" section.

  • Daisyhead
    Member
    Posted 10 years ago #

    MtDew, do you write all the hacks around here? ;-) Or just know everything? 'Cuz you are all over the board helping everyone. What a guy! =)
    Thanks for all your help!

  • Nick Momrik
    Member
    Posted 10 years ago #

    I just try to help out as much as I can. :-)

  • Anonymous
    Unregistered
    Posted 10 years ago #

    Daisyhead yes you can i'll post how to do it in a sec when I figure out whats going on..... MtDewVirus, What exactly isn't working correctly? I don't see the problem that you are talking about.

  • Nick Momrik
    Member
    Posted 10 years ago #

    The query doesn't exactly pull the ID and comment_ID for the last comment by a visitor. At least not from my testing of it. The GROUP BY messes this up. I ran into a similar problem with a hack I wrote and was able to fix it by callin for MAX(comment_ID), but then how do you get the correct ID? You can't pull the MAX(ID) because the latest post commented on by a visitor may not be their latest comment. See what I mean?
    I was running the query through phpMyAdmin, trying to get the correct results but so far have been unable to.

  • Daisyhead
    Member
    Posted 10 years ago #

    You guys are great! I can live without the last date commented. I don't mean to be such a pest. Maybe I just need to tweak my output so it will say:
    Jess - 184 total
    last on entry: (entry title last commented on w/link to entry)
    Is there a way to change that?

  • Hamoudy
    Member
    Posted 10 years ago #

    Hey Daisyhead
    Does the "Last" at the end of your comments leader actually works? and bring up the latest comment by that user?

  • Anonymous
    Unregistered
    Posted 10 years ago #

    No not at the moment, I'm about to post an updated fixed version later on today.

  • TechGnome
    Moderator
    Posted 10 years ago #

    Kudos to doniboy (and everyone else who had a hand in it)! The hack works splendidly. It was easy to set up and get running. See it On my site. Woo-hoo!
    TG

  • Nick Momrik
    Member
    Posted 10 years ago #

    TG,
    The portion of the hack that display a link to a commentors last comment is not working correctly yet. I tried to come up with the correct SQL to fix this, but have been unsuccessful yet. doniboy is still working on it also. :-/

  • TechGnome
    Moderator
    Posted 10 years ago #

    Hrm.... I thought it was, but I see now that it doesn't ;) that's OK... if you need my help, just ask (I am a developer by trade and do a lot of SQL).....
    TG

  • Hamoudy
    Member
    Posted 10 years ago #

    ~TG
    If you can figure this out why it's not giving the last comment. That would be Great. :)
    thanks in advance

  • Nick Momrik
    Member
    Posted 10 years ago #

    But....the max comment_post_ID may not be the post that was last commented on. ;) What if a commentor went back and commented on a post from a week ago. That will have the max comment_ID, but pulling the max comment_post_ID will post to the latest post they have commented on. Man, that sounds confusing!

  • TechGnome
    Moderator
    Posted 10 years ago #

    hmmmmm.... I see your point.... OK, I sit corrected.... I'll take a further look at it when I get home (and don't have thinkgs like work cluttering my brain).....
    TG
    I bet the answer is so simple, that it's rediculous....

  • Nick Momrik
    Member
    Posted 10 years ago #

    It usually is... :-/

  • Anonymous
    Unregistered
    Posted 10 years ago #

    Yes I concidered using MAX and have cam across the same problems. I'm going to have to take that part of the code out and only show the commentor's name and number of comments into I figure out the best way to do this.. It's giving me a hard time also.

  • Anonymous
    Unregistered
    Posted 10 years ago #

    Also another problem is how would we go about joining the comment table with the post table so that I can get the title of the last post that the commentor commented on. We'll have the same problem with it pulling the earliest title field instead of the latest one. MAX won't work on this because its a string and it'll sort it in an alphabetical order.
    Any suggestions TechGnome?

  • TechGnome
    Moderator
    Posted 10 years ago #

    Yeah, I do have an idea.... unfortunatly it will need to wait until I get home, where I can run MyPHPAdmin properly to test the theory out. I think two selects Joined together somehow will be the answer.
    Alex - I didn't think that MySQL 4 supported Inner Selects, but that was something 5.0 was going to support.... hrmm.... I don't know.... ;)
    I will look at it tonight and see what I can do....
    TG

  • TechGnome
    Moderator
    Posted 10 years ago #

    Wuuuup!
    Latest version of comment leaders hack can be found right here! It appears to work for me now, getting the proper post AND comment. I would appreciate it if I could get some "independant" confirmation on this.
    Unfortunatly, I could not get it to work with one SQL call, and broke it up into two calls.
    TG

  • Hamoudy
    Member
    Posted 10 years ago #

    ~TG
    Good Job man... It works just fine. Way to Go. Check it out Here
    It's under the Recent Tab ;)
    Thanks again!

  • Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    Two cheers for the Gnome.

  • 12

    Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.