show un-approved comments at wordpress front end

I’ve almost finished coding up a function that allows contributers when they are the post author to manage comments left on their own post (portfolio) couldnt find a plugin to do it so had to get myself dirty.

It will basically work like this:

1) User leaves a comment on post_authors portfolio.

2) Post_author is notified by email that they have a comment for moderation (this bit is handled by a plugin “notify-on-comments”).

3) Post_author logs in and goes to his/her portfolio page and in the comments are two links one for “delete” and one for “approve” comment.

Now i can get the delete to work on already published comments, my problem is that i am wanting to show the unpublished comment along with the published comments (dont want folks having access to wp-admin dashboard to moderate comments, i want it all done on the front end),

Does anyone know how i can do this part of showing the un-approved comment at front-end to contributers?

Once completed i will be more than happy to share the code and credits should anyone else need it.

Regards and thanks in advance

Solutions Collecting From Web of "show un-approved comments at wordpress front end"

Easy:

function show_portfolio_comments( $post_ID ) 
{
    // NOT approved
    $comments_unapproved = get_comments( array( 'status' => 'hold', 'post_id' => $post_ID ) );
    foreach ( $comments_unapproved as $comments) 
    {
      if ( current_user_can( 'edit_published_posts' ) // maybe you'll have to switch to some other cap 
      {
      ?>
      <div class="comment">
         <h4>Unapproved Comments on your portfolio</h4>
         <div class="comment-author"><?php echo $comment->comment_author; ?></div>
         <div class="comment-content"><?php echo $comment->comment_content; ?></div>
      </div>
      <?php
      } // endif; - current_user_can( 'edit_published_posts' )
    }

    // ALREADY approved
    $comments_approved = get_comments( array( 'status' => 'approve', 'post_id' => $post_ID ) );
    foreach ( $comments_approved as $comments) 
    {
      ?>
      <div class="comment">
      <?php if ( current_user_can( 'edit_published_post' ) { ?>
         <h4>Approved Comments on your portfolio</h4>
      <?php }  // endif; - current_user_can( 'edit_published_posts' ) ?>
         <div class="comment-author"><?php echo $comment->comment_author; ?></div>
         <div class="comment-content"><?php echo $comment->comment_content; ?></div>
      </div>
      <?php
    }
}

Template Tag:

// Use it in your template like this & don't forget to push the post ID into it:
$post_ID = $GLOBALS['post']->ID;
// or:
global $post;
$post_ID = $post->ID;
// or:
$post_ID = get_the_ID();
// or:
$post_ID = get_queried_object_id();

show_portfolio_comments( $post_ID );