MyBB Community Forums

Full Version: Show avatar when quoting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
First of all greetings Smile I have a question, I want to show the avatar when quoting someone in a post like this.

[Image: avatarik.jpg]

Try to modify this part in the file inc / functions_posting.php

	$get_uavatarq =	$db->simple_select("users", "avatar", "username = '{$quoted_post['username']}'");
	print_r($get_uavatarq);
	
	return "[quote='{$quoted_post['username']}' pid='{$quoted_post['pid']}' dateline='{$quoted_post['dateline']}']\n{$quoted_post['message']}\n[/quote]\n\n";

I can do?
In ./inc/functions_posting.php , find;
global $parser, $lang, $plugins;
and Change it into;
global $db, $mybb, $parser, $lang, $plugins;

Next, find;
$quoted_post = $plugins->run_hooks("parse_quoted_message", $quoted_post);
and ADD the following code just on the next line;
	$query = $db->simple_select("users", "avatar", "username='{$quoted_post['username']}'");
	$avatar = $db->fetch_array($query);
	
	if ($avatar['avatar'] != "")
	{
		$quoted_post['avatar'] = '[img]'.$mybb->settings['bburl'].'/'.$avatar['avatar'].'[/img]';
	}
	else
	{
		$quoted_post['avatar'] = '[img]http://www.yourdomain.com/images/default_avatar.gif[/img]';
	}

Next, find;
return "[quote='{$quoted_post['username']}' pid='{$quoted_post['pid']}' dateline='{$quoted_post['dateline']}']\n{$quoted_post['message']}\n[/quote]\n\n";
and Change it into;
return "{$quoted_post['avatar']}[quote='{$quoted_post['username']}' pid='{$quoted_post['pid']}' dateline='{$quoted_post['dateline']}']\n{$quoted_post['message']}\n[/quote]\n\n";

It will result into this;
[attachment=27213]

You may play with the code to adjust it that way you want Smile
This good, but I only doubt arises, with the code you put anyone can delete the BB code [IMG] at the time of quoting the message. how I can make this "static" and shown only at the time the message is published.

If it's not too much trouble ..

PS: Sorry for my bad English, but only speak Spanish.

Someone can help me?