MyBB Community Forums

Full Version: Plugin embed user avatar? Syntax error.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Alright, so I'm trying to modify a plugin to use a user's avatar rather tan a static image.

Here is the new updated code.

$i_avatar = '<a href="member.php?action=profile&amp;uid='.$uid.'"><img src=\"$mybb->user['avatar']\" alt="'.$user['username'].'" title="'.$user['username'].'" width="35px" height="35px" class="i_update_avatar"></a>';

I'm getting a
Parse error: syntax error, unexpected T_STRING in

Error.

I've tried other things like without the \ and without the {} but the issue remains.
$i_avatar = '<a href="member.php?action=profile&amp;uid='.$uid.'"><img src=\"{$mybb->user['avatar']}\" alt="'.$user['username'].'" title="'.$user['username'].'"></a>';

I managed to edit rid of the error by using.
{$user[\'avatar\']}

However, now the image does not want to display.
http://mydomain.com/%7B$user['avatar']%7D

^ is the output to a broken image.

Any ideas?
$i_avatar = '<a href="member.php?action=profile&amp;uid='.$uid.'"><img src="'.$mybb->user['avatar'].'" alt="'.$user['username'].'" title="'.$user['username'].'"></a>';

But I don't think that code is proper anyway. It will display your avatar, not from the person which is the $user in query.

You need something like that:
$their_avatar_src = $user['avatar'] ? $user['avatar'] : 'images/default_avatar.gif';
$their_avatar = '<img src="'.$their_avatar_src.'" alt="'.$user['username'].'" title="'.$user['username'].'">';
$i_avatar = '<a href="member.php?action=profile&amp;uid='.$uid.'">'.$their_avatar.'</a>';

Make sure the avatar column is selected from mybb_users in the query, otherwise it won't work.