I use this micro message system script and I want to add an avatar to it, however, my lack of PHP knowledge is making this difficult.
The code I use to display an avatar is:
userphoto_thumbnail($user_info, $before = '', $after = '', $attributes = array(width => '40', height => '40'), $default_src = '')
And I want to inject this avatar to this part of the message script (inside a loop):
$r = $r . '<tr id="wpam-reply-' . $post->post_ID . '-' . $count . '" ' . $style . '>';
$r = $r . '<td style="padding:10px 0 10px 10px; width:40px;"><span title="' . $user_info->display_name . ' (' . $user_info->user_login . ')">' . userphoto_thumbnail($user_info, $before = '', $after = '', $attributes = array(width => '40', height => '40'), $default_src = '') . '</span></td>';
$r = $r . '<td>' . wpam_get_message($reply, $user_info, $options, 2) . '</td>';
$r = $r . '</tr>';
If you look at the second line, you will see how I added it there. However, this does not return the avatar where it should be. It appears outside everything else. Maybe because it returns a string rather than data? I am not sure as I am only just familiarising myself with PHP terminology.
I am certain that I have not added the avatar code to the script correctly, can you assist?
EDIT: Just to clarify, on the HTML output, the avatar images appear outside of the table, when they should be inside the <td style="padding:10px 0 10px 10px; width:40px;"> tag.
From the documentation, it looks like
userphoto_thumbnailsprints out the image. You’re trying to concatenate it instead. When you call it, it’s being printed out when you’re creating the string, so it’s appearing in the wrong place.Try this:
That will print everything out in the right place, though you’re no longer creating the
$rvariable.