$5
User Photo in Get Recent Comments Widget
I could not figure out any other way to get two plugins together, which harmonize.
As i suggest, one has two write a macro-function, which Get Recent Comment makes use of. This function should generate the thumbnail of the user photo.
Or you could simply find a way to use php tags in the template for the recent comments.
philip warschkow | 05/26/10 at 4:29pm
| Edit
(3) Possible Answers Submitted...
-

Last edited:
05/27/10
12:42amEhthisham tk says:this code will display recent comment with the author's gravatar no plugin needed
<?php
$total_comments = $wpdb->get_results("SELECT comment_date_gmt, comment_author, comment_ID, comment_post_ID, comment_author_email FROM $wpdb->comments WHERE comment_approved = '1' and comment_type != 'trackback' ORDER BY comment_date_gmt DESC LIMIT 10");
$comment_total = count($total_comments);
echo '<ul>';
for ($comments = 0; $comments < $comment_total; $comments++) {
echo "<div style='clear:both;width:355px;padding-top:3px;'><div style='float:left;width:35px;'>";
echo get_avatar($total_comments[$comments]->comment_author_email,$size='32',$default='<path_to_url>' );
echo "</div> <div style='width:320px;'>";
echo '<li>';
echo $total_comments[$comments]->comment_author . ' says ';
echo '<a href="'. get_permalink($total_comments[$comments]->comment_post_ID) . '#comment-' . $total_comments[$comments]->comment_ID . '">';
echo get_the_title($total_comments[$comments]->comment_post_ID);
echo '</a></li></div></div>';
}
echo '</ul>'
?>
- 05/27/10 1:48am
philip warschkow says:Ok this would take a lot of effort to implement this.
But i want USER PHOTO not GRAVATAR.
So i must put in s.th. like that: userphoto_comment_author_thumbnail()
I'll try...
- 05/27/10 2:14am
Ehthisham tk says:yea sure.You can also try this if the user has no userphoto then display the gravatar
<?php
if(userphoto_exists($user))
userphoto($user);
else
echo get_avatar($user->ID, 96);
?>
- 05/27/10 1:48am
-

Last edited:
05/29/10
3:21amB L says:The recent comments plugin suggests using the profile pic plugin and then using the %profile_picture macro to insert the author images. This is probably the easiest if you don't want to get your hands dirty in the code.
You will not simply be able to use userphoto_comment_author_thumbnail() because that will echo the images directly to the HTML stream rather than append the string to the output variable that the recent comments plugin uses....... Thus your images will not end up where you want them to be.
A quick and dirty hack if you want to continue to use the user photo plugin would be to edit the recent comments plugin code. On line 1380, change:
$output = str_replace("%profile_picture", '', $output);
to
$output = str_replace("%profile_picture", userphoto__get_userphoto($comment->user_id, 2, '','','',''), $output);
(note the double underscore instead of single)
Then go back to your recent comments settings and add in the %profile_picture macro in the location you want the picture to end up.- 05/27/10 10:41am
B L says:You cannot simply use userphoto_comment_author_thumbnail() because it will echo the images directly rather than concatinate a string to the output variable the recent comments plugin requires.
You could put a bit of a dirty hack in by changing line 1380 from
$output = str_replace("%profile_picture", '', $output);
to
$output = str_replace("%profile_picture", userphoto__get_userphoto($comment->user_id, 2, '','','',''), $output);
Then put the %profile_picture macro in the settings of the get recent comment plugin at the point you want it to display
Alternatively, use the profile pic plugin suggested in the get recent comments plugin and add the %profile_picture macro - 05/27/10 11:11am
philip warschkow says:ok. i try that! sounds good! I also tried Profile Pic-plugin which produces an error when uploading the profile pic:
Warning: Invalid argument supplied for foreach() in /www/htdocs/w00bfdc8/wp-content/plugins/profile-pic/profile-pic.php on line 422
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/w00bfdc8/wp-content/plugins/profile-pic/profile-pic.php:422) in /www/htdocs/w00bfdc8/wp-includes/pluggable.php on line 868
Could you mess two more macros for me?
- 05/27/10 2:26pm
philip warschkow says:ok. works.
how can i change this line
if (empty($author_url) || $author_url == "http://")
into
if (empty($author_url) || $author_url == "BLOGURL/profile/user-nicename") - 05/27/10 3:09pm
philip warschkow says:AND: unfortunately the widget does not show anything, when a user is not registered. Is there a way to do that?
- 05/27/10 10:41am
-

Last edited:
05/28/10
4:12amSmashinGeeks says:What I suggest you in order to get recent comments with gravatar is that, you should use this plugin.
Recent Comments By Rob Marsh
After downloading the plugin, activate it and jump to Recent Comments Option usder Settings tab. And then go to "Output" link under the heading. In the output code, place this code :
<p>
<img src="{gravatar}" width="50" height="50" alt="" />{link}
<div class="clear"></div>
</p>
You can choose custom size of the gravatar.Also you can spice it up with some CSS code :
#recent-comments h3 { font-size: 1.8em; letter-spacing: normal; padding-top: 15px; }
#recent-comments{ float: left; width: 50%; }
#recent-comments p { margin-bottom: 15px; padding: 10px 2.5em 10px 10px; }
#recent-comments a { font-size: 1.4em; border-bottom: 1px solid #CB3131; line-height: 1.5em; }
#recent-comments a:hover { border: 0; }
#recent-comments h3 { padding-left: 10px; }
This question has expired.
Current status of this question: Completed





