MyBB Community Forums

Full Version: Member profile and Skunk Medal plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

I was just wondering if there is a way to display the medals a member has in the member profile under the stars of the profile table?
I have actually tried to figure this out but just couldn't. Would be nice it someone could figure it out and let the rest of us know. LOL
yayy! yes, that is exactly what I was looking for. Either in its own row or section like that one or where the Admin icons are under the stars.
Hmm...leave it to Lex to have figured it out. Have you shared how to do it? Toungue
Will show it when i get home from work, that's within 10hours =P

Open ./inc/plugins/medals.php

Find
$plugins->add_hook("postbit", "get_medals");

Add below
$plugins->add_hook("member_profile_end", "get_medals_mem");

Find
function get_medals($post)

Add above
function get_medals_mem()
{

global $db, $mybb,$config, $memprofile, $medals;
$uid=intval($memprofile['uid']);

// check Number of medals, exit if no medals
$query = $db->simple_select(TABLE_PREFIX.'medals_awarded', 'COUNT(*) AS count',"uid=".$uid);
	$medal_count = $db->fetch_array($query);
	if($medal_count['count'] > 0)
	{
	$medals = "<div style=\"white-space: normal; width:100%;\">";
        $medals_query = $db->query("select `mid` from `". TABLE_PREFIX."medals_awarded` where `uid`='".$uid."'");
		while($medals_list = $db->fetch_array($medals_query))
        	{
                $medal_query = $db->query("select `mid`,`description` from `".TABLE_PREFIX."medals_list` where `mid` = '".$medals_list['mid']."'");
		$medal = $db->fetch_array($medal_query);
	        $imgsrc = $mybb->settings['bburl']."/".$mybb->settings['uploadspath'].'/medals/'.$medal['mid'].'.jpg';
		$medals .= " <img src=\"{$imgsrc}\" alt=\"{$medal['description']}\"  title=\"{$medal['description']}\" border=\"0\" />";
		}
	$medals .= "</div>";
	}
	if(!$medals)
	{
		$medals = "No Medals";
	}
}

After saving and reuploading the file, you should be able to use {$medals} in your member_profile template to show the medals.
Works! Thanks for sharing. Big Grin
I dont know what I am doing wrong. I updated the medals template and uploaded.

I added this to member_profile:

<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->profile}</title>
{$headerinclude}
</head>
<body>
{$header}
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><img src="{$theme['imgdir']}/thead_l.png" alt="" /></td>
<td class="thead" style="white-space:nowrap">{$lang->profile}</td>
<td><img src="{$theme['imgdir']}/thead2.png" alt="" /></td>
<td class="thead2"></td>
<td><img src="{$theme['imgdir']}/thead_r.png" alt="" /></td>
</tr>
</table>
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="trow1" width="75%">
<span class="largetext"><strong>{$formattedname}</strong></span><br />
<span class="smalltext">
({$usertitle})<br />
{$groupimage}
{$userstars}<br />
{$medals}<br />

<br />

Did I do something wrong?
You need to make the edits to the actual plugin file, not the template. If you did, then maybe you did something wrong. Here's my edited file that you can try if you want.
judel Wrote:You need to make the edits to the actual plugin file, not the template.

I'm sorry, that is what I meant to say. I did do the actual edit to the medals.php file.
Pages: 1 2