Thanks for your post.
if your theme used get_avatar()
function to display comment avatar then you can use following code to display user profile image.
add_filter('get_avatar', 'site_get_avatar', 10, 5);
function site_get_avatar($avatar, $id_or_email, $size, $default, $alt){
$comment_author_id = $id_or_email->user_id;
$comment_author_email = $id_or_email->comment_author_email;
$user_profile_img_id = get_the_author_meta( 'user_profile_img', $comment_author_id );
$user_profile_img = wp_get_attachment_url($user_profile_img_id);
$my_avatar = "<img src='".$user_profile_img."' alt='".$alt."' height='".$size."' width='".$size."' />";
return $my_avatar;
}
thank a lot for response, I need insert this code in functions.php of theme?
I tried and show avatar in comments but appear following error notice:
Notice: Trying to get property of non-object in /public_html/social/wp-content/themes/mesocolumn/functions.php on line 320
Could you help me? Very kinds, thanks again and sorry my english
-
This reply was modified 6 years, 10 months ago by trevius.
The issue is in the strings
$comment_author_id = $id_or_email->user_id;
$comment_author_email = $id_or_email->comment_author_email;
-
This reply was modified 6 years, 10 months ago by trevius.
Thanks for your reply.
we need to look at your comments.php file in your theme directory. the filter depends on which function used to display the avatar.
if you please send me your theme zip file then I can help you better way.
Regards
The avatar display correctly, I disabled wp debug for hide notice and anything work.
At the moment thanks a lot.
Respects