WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Get Author's Comments

Get Author's Comments displays or retrieves a list of comments posted by a user.

Usage

Display all comments of a specific user in the current post

<?php
    <ol>
        <?php ppm_author_comments('piouPiouM', 'foo@example.com'); ?>
    </ol>
?>

or, if piouPiouM wrote with two different emails:

<?php
    <ol>
        <?php ppm_author_comments('piouPiouM', array('foo@example.com', 'bar@example.org')); ?>
    </ol>
?>

Display all comments posted by a user

<?php
    <ol>
        <?php ppm_author_comments('piouPiouM', 'foo@example.com', null, 'all=1'); ?>
    </ol>
?>

Display comments wrote by a user in the post of ID number 9

<?php
    <ol>
        <?php ppm_author_comments('piouPiouM', 'foo@example.com', 9); ?>
    </ol>
?>

Note: If you used the tags ppm_author_comments or ppm_get_author_comments whithin The Loop, the parameter $postID will be replaced automatically by the numeric ID of the current post.

Lastest comments ordered by post_ID

To show the last ten piouPiouM's comments sorted by post_ID in ascending order, the following will display their comment date and excerpt:

<?php
    $comments = ppm_get_author_comments('piouPiouM', 'foo@example.com', null, 'number=10&order=ASC&orderby=post_id');
    foreach ($comments as $comment):
?>
<p><cite><?php comment_author_link() ?></cite> says:</p>
<ol>
    <li>
        <p>Comment posted on <?php comment_date('n-j-Y'); ?>:<br/></p>
        <p><?php comment_excerpt(); ?></p>
    </li>
</ol>
<?php endforeach; ?>

Comments with a custom comment display

<?php
    <ol>
        <?php ppm_author_comments('piouPiouM', 'info@example.com', null, 'callback=mytheme_comment'); ?>
    </ol>
?>

See Comments Only With A Custom Comment Display for an example of a custom callback function.

Show the total number of comments posted by a user on the site

<?php
    get_currentuserinfo();
    $comments = ppm_get_author_comments($current_user->display_name, $current_user->user_email, null, 'all=1');
    printf('Hello ! <a href="/author/%s/">%s</a>! '
         . '[ <a href="%s" class="logout">Log Out</a> ]<br/>'
         . '%d posts and %d comments',
        $current_user->user_login,
        $current_user->display_name,
        wp_logout_url(),
        get_usernumposts($current_user->ID),
        count($comments));
?>

Parameters

all
(boolean) (optional) Retrieve all comments. Default to FALSE.

number
(integer) (optional) Number of comments to return. Default to None, returns all comments.

offset
(integer) (optional) Offset from latest comment. Default to 0.

orderby
(string) (optional) Sort posts by one of various values (separated by space), including:

  • 'comment_ID' - Sort by numeric comment ID.
  • 'content' - Sort by content.
  • 'date' - Sort by creation date. (Default)
  • 'post_ID' - Sort by post ID.
  • 'rand' - Sort in random order.
  • 'status' - Sort by status.
  • 'type' - Sort by type.

order
(string) (optional) Sort order, ascending or descending for the orderby parameter. Valid values:

  • 'ASC' - Ascending (lowest to highest).
  • 'DESC' - Descending (highest to lowest). (Default)

output
(string) (optional) How you'd like the result. Only for ppm_get_author_comments.

  • OBJECT - Returns an object. (Default)
  • ARRAY_A - Returns an associative array of field names to values.
  • ARRAY_N - Returns a numeric array of field values.
  • HTML - Returns a (x)HTML version generated by wp_list_comments.

status
(string) (optional) The comments status. Default to hold and approve. Valid values:

  • 'hold' - Unapproved.
  • 'approve' - Approved.
  • 'spam' - Spam.

Requires: 2.7-beta1 or higher
Compatible up to: 2.9.2
Last Updated: 2009-8-2
Downloads: 1,656

Ratings

4 stars
4.5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
0,1,0