Avatar appears outside of targeted area when adding it to a PHP messaging script

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_thumbnails prints 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:

echo '<tr id="wpam-reply-' . $post->post_ID . '-' . $count . '" ' . $style . '>';
echo '<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 = '');
echo . '</span></td>';
echo '<td>' . wpam_get_message($reply, $user_info, $options, 2) . '</td>';
echo '</tr>';

That will print everything out in the right place, though you're no longer creating the $r variable.

Need Your Help

How can I set a variable on a _Layout page?

asp.net-mvc asp.net-mvc-3 razor

I have a view and I want to use a layout page. In the layout page I want to have a conditional banner which some of the view will turn on/off. Just wondering how I can do this?

How do you allocate memory at a predetermined location?

memory-management new-operator placement-new

How do i allocate memory using new at a fixed location? My book says to do this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.