x
 
Create New Page
 View Previous Changes    ( Last updated by johnniefp )

Display pending comments only to comment author

Problem

I had a requirement where moderated comments needed to be displayed instantly to the comment author, even though the comment was not yet approved.

Requirements

1: Query module
2: PHP parsed on input for your template/embed.

The code below will display a comment to the comment author *only*, the comment can be as abusive as they wish - only they will see it, I think you get the scenario.

{exp:query sql="SELECT author_id, name, status, comment, comment_date
                  FROM exp_comments
                 WHERE status ='c'
                   AND author_id='<?php global 
$SESS; echo $SESS->userdata('member_id');?>'
                   AND entry_id = '{entry_id}';"
}
             
<div class="comment-info">Comment posted by <strong>{name}</strong>  on  {comment_date format='%d %M %Y'}  at  {comment_date format='%h:%i %A'}</div>
             <
div class="comment"><p><em>This comment is awaiting moderation.</em></p>{comment}</div><!-- end comment -->
{/exp:query} 

Thank you

A quick post on the forum gave me input from Ingmar (as always) and lesibol, thanks to both.

Category:EE1

Categories: