Categories
Package/plugin/module WordPress

Plugin: Recent Commenters

UPDATE:
This plugin has been superceded by the more robust Top/Recent Comments plugin.
Name:
Recent Commenters
Author:
Scott Reilly
Version:
0.9
Last updated:
07 July 2004
Description:
Retrieve the last N people who have most recently commented. Note this is different than saying “the people who made the N most recent comments.”

Notes:

This plugin outputs a list of the N most recently commenting authors (with hyperlinks to their homepage if they provided an URL). You can define $before and $after text/HTML to bookend each list item. Specify $num_people to control how many people to list.

  • Can be used inside or outside “the loop”
Installation:
Install the Top/Recent Comments plugin insead.
Functions:
[I’ve defined the $num_posts arg as 2 for all of the examples in order to limit the amount of sample output.]

get_recent_commenters($num_people = 5, $before='<li>', $after='</li>')

  • $num_people : The number of recent commenters to be returned; default is 5
  • $before: The text to display before each recent commenter.
  • $after: The text/HTML to display after each recent commenter.
Tips & Examples:

Example:

<ul> <?php get_recent_commenters(3); ?> </ul>

Outputs:

<ul> <li><a href="http://www.joebob.org">Joe Bob</a></li> <li>No Homepage Guy</li> <li><a href="http://www.suzy.org">Suzy</a></li> </ul>

Example:

Recent love from: <?php get_recent_commenters(3, '', ','); ?>

Outputs:

Recent love from: <a href="http://www.joebob.org">Joe Bob</a>, No Homepage Guy, <a href="http://www.suzy.org">Suzy</a>,

Release Log:
  • 08 Jul 2004 : Deprecated; use the Top/Recent Comments plugin insead.
  • 07 Jul 2004 : v0.9 — Released to the public
Copyright & Disclaimer:

Copyright (c) 2004, Scott Reilly
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of coffee2code.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Acknowledgements:
I’d like to thank Nick Momrik since I used his Recent Comments and Recent Posts plugins as a starting point for this plugin.

12 replies on “Plugin: Recent Commenters”

Any chance I can nest this within the Recently Commented function? I am trying to replicate what I did here in MT. It shows the ten most recently commented-on posts and the three most recent authors and times of the comment.

Thanks for your hard work. These are awesome plug-ins!

Yours was a little more complex to implement than Icyshard’s request, but I think I did it. Go here and refer to the second function on that page, sample2_recently_commented(). Theoretically, you’d just have to do:

&lt;?php sample2_recently_commented(); ?>

and you’d get what you currently have under MT. Like I said for Icyshard, you can paste that function into your copy of recently_commented.php, or into the myhacks.php file (you’ll have to find help on using that file yourself). Hope it helps!

Hmmm, can you verify that in your sample2_recently_commented() function, that the call to get_recently_commented() (a call which is necessary) does NOT have ANY spaces between the pair of single-quote characters in the second and third argument to the function. Should be like:

get_recently_commented($num_posts, '', '')


If the second and third arguments are ” (a pair of single-quotes without a space in between), get_recently_commented() is not supposed to echo/display the basic formatting. So I’d like to rule out the simple stuff. It ran fine for me on a test blog.

Sorry to be such a pain in your ass, but I think I fixed it! I had a bunch of configurations in the get_recent_commenters from when I was messing with that. I cleared those out and now it looks good.

Thanks again, and sorry again! Keep the great plug-ins coming…

Sorry to keep borthing you, Scott. I have a small problem, my recent comments list is showing comments that haven’t been approved yet! Is there a setting I can toggle in your script to only display approved comments?

As always, thanks for your amazing work!

Ruby,
Revisit the page where I posted your customized code (linked via the second comment in this post). I’ve updated it to omit unapproved comments. The updated line of code, reproduced below, was given this new bit: comment_approved = '1' AND

$sql = "SELECT comment_date, comment_author, comment_ID FROM $tablecomments WHERE comment_approved = '1' AND comment_post_ID = $row->ID ORDER BY comment_date DESC LIMIT $num_show_comments";

[…] UPDATE There’s been a bit of debate about the need for a central database of plugins. There’s a lot of developers now developing plugins, and it’s quite a task to find them as a user, as well as a developer to see if something you want to do has already been done. In any case – this plugin has apparently already been done by coffee2code.com (with only some minimal differences). […]