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

Display single comment by logged in user

I needed this functionality to allow a user who is logged in to the website to only see comments they post.

This code was contributed to by Mark Bowen and Ingmar Greil and is discussed in this forum post.

If you view the template using this sort of URL:
http://www.example.com/latest-comment/my_entry_url_title, you should get the last comment posted by the currently logged-in user for that entry.

<?php
global $SESS;
$author_id $SESS->userdata['member_id'];
?>

{exp
:weblog:entries weblog="default_site" disable="member_data|trackbacks|pagination|categories|category_fields"}

{exp
:query sql="

SELECT comment as the_comment, comment_date FROM exp_comments
WHERE weblog_id = '1' AND site_id = '1' AND status = 'o'
AND author_id = '<?php echo 
$author_id; ?>' AND entry_id = '{entry_id}'
ORDER BY comment_date DESC LIMIT 1"
}

<p>You posted the following response to this taskYou last edited this on {comment_date format="%d %F %Y at %G:%i"}.</p>
<
p>{the_comment}</p>

{/exp:query}

{
/exp:weblog:entries} 

Category:Comments

Category:EE1

Categories: