MyBB Community Forums

Full Version: [GUIDE] How to add a Donate Button near User Avatar in threads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanted to know how I could do something like this:

[Image: snapshot6.jpg]

Here's a bigger picture:
[Image: snapshot7.jpg]

Notice the "Donate to me" button above the user Avatar? I wanted to add a small rectangular image like that above the avatar, and which has a URL associated with it. I did a bit of searching for any plugin with this function and couldnt find it.

I solved it.

First,
I added a custom profile field called Donation Link. It had an id of 4.

Then installed this plugin: PHP and Template Conditionals
This is because I do not want this field to display if user has not filled it.

Then, I had to modify the postbit template, under the span tag of "smalltext":
Home » Template Sets » Default Templates -> postbit_classic

If you use other template, you will have to modify that as well.

Added the following code:
<if !empty($post['fid3']) then>
Donation Link: <br /><a href="{$post['fid4']}"><img src="http://path_to_donation_link_image.png"></a><br />	
</if>

Between {$post['groupimage']} and {$post['useravatar']}

I had to add a few <br /> tags to get correct formatting.

Final code is like this:
<span class="smalltext">
			{$post['usertitle']}<br />
			{$post['userstars']}
			{$post['groupimage']} <br />
			<if !empty($post['fid3']) then>
Donation Link: <br /><a href="{$post['fid4']}"><img src="http://path_to_donation_link_image.png"></a>	<br />	
</if>	
			{$post['useravatar']}<br />
			{$post['user_details']}
		</span>


Activating it on my forum gives me this:
[Image: snapshot8.jpg]
Admin Control panel > Templates > Your theme's templates > Postbit Templates > postbit_classic > and find;
{$post['useravatar']}
and Add the following code just above it;
<a href="LINK TO YOUR DONATE"><img src="PATH TO YOUR DONATE BUTTON" alt="" title="Donate"></a>
<br />
Hmm...wouldnt that add the same link to all users? I would like the user to set the Donate link of his own at registration, and later in his profile (user editable).
Then you can use Custom profile Field for this.
(2011-11-16, 05:23 AM)Yaldaram Wrote: [ -> ]Then you can use Custom profile Field for this.

Thank you. I will try this. Smile
(2011-11-16, 05:23 AM)Yaldaram Wrote: [ -> ]Then you can use Custom profile Field for this.

Ok, following one of your tutorials, I have added the following to member_profile of default template:

<br/>
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
        <td class="thead">
        <strong></strong>
        </td>
    </tr>
    <tr>
        <td class="trow1"><A HREF="{$userfields['fid4']}" target="_blank"><img src="http://droidzone.in/romforum/images/donate.png" alt="Donate to me" /></A>
        </td>
    </tr>
</table>

The custom profile field with a Donate link has an ID of 4
But nothing happens. Profile remains as it was. Did I add it in the wrong place?


This is the full code:
<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->profile}</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="trow1">
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td class="trow1" width="75%">
<span class="largetext"><strong>{$formattedname}</strong></span><br />
<span class="smalltext">
({$usertitle})<br />
{$groupimage}
{$userstars}<br />
<br />
<strong>{$lang->registration_date}</strong> {$memregdate}<br />
<strong>{$lang->date_of_birth}</strong> {$membday} {$membdayage}<br />
<strong>{$lang->local_time}</strong> {$localtime}<br />
<strong>{$lang->postbit_status}</strong> {$online_status}
</span>
</td><td width="25%" align="right" valign="middle">{$avatar}</td></tr></table>
</td>
</tr>
{$awaybit}
</table>
<br />
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
<td width="50%" valign="top">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td colspan="2" class="thead"><strong>{$lang->users_forum_info}</strong></td>
</tr>
<tr>
<td class="trow1"><strong>{$lang->joined}</strong></td>
<td class="trow1">{$memregdate}</td>
</tr>
<tr>
<td class="trow2"><strong>{$lang->lastvisit}</strong></td>
<td class="trow2">{$memlastvisitdate} {$memlastvisittime}</td>
</tr>
<tr>
<td class="trow1"><strong>{$lang->total_posts}</strong></td>
<td class="trow1">{$memprofile['postnum']} ({$lang->ppd_percent_total})<br /><span class="smalltext">(<a href="search.php?action=finduserthreads&amp;uid={$uid}">{$lang->find_threads}</a> &mdash; <a href="search.php?action=finduser&amp;uid={$uid}">{$lang->find_posts}</a>)</span></td>
</tr>
{$tyl_memprofile}
<tr>
<td class="trow2"><strong>{$lang->timeonline}</strong></td>
<td class="trow2">{$timeonline}</td>
</tr>
{$referrals}
{$reputation}
{$warning_level}
</table>
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td colspan="2" class="thead"><strong>{$lang->users_contact_details}</strong></td>
</tr>
<tr>
<td class="trow1" width="40%"><strong>{$lang->homepage}</strong></td>
<td class="trow1">{$website}</td>
</tr>
{$sendemail}
<tr>
<td class="{$bgcolors['pm']}"><strong>{$lang->pm}</strong></td>
<td class="{$bgcolors['pm']}"><a href="private.php?action=send&amp;uid={$memprofile['uid']}">{$lang->send_pm}</a></td>
</tr>
<tr>
<td class="{$bgcolors['icq']}"><strong>{$lang->icq_number}</strong></td>
<td class="{$bgcolors['icq']}">{$memprofile['icq']}</td>
</tr>
<tr>
<td class="{$bgcolors['aim']}"><strong>{$lang->aim_screenname}</strong></td>
<td class="{$bgcolors['aim']}"><a href="javascript:;" onclick="MyBB.popupWindow('misc.php?action=imcenter&amp;imtype=aim&amp;uid={$uid}', 'imcenter', 450, 300);">{$memprofile['aim']}</a></td>
</tr>
<tr>
<td class="{$bgcolors['yahoo']}"><strong>{$lang->yahoo_id}</strong></td>
<td class="{$bgcolors['yahoo']}"><a href="javascript:;" onclick="MyBB.popupWindow('misc.php?action=imcenter&amp;imtype=yahoo&amp;uid={$uid}', 'imcenter', 450, 300);">{$memprofile['yahoo']}</a></td>
</tr>
<tr>
<td class="{$bgcolors['msn']}"><strong>{$lang->msn}</strong></td>
<td class="{$bgcolors['msn']}"><a href="javascript:;" onclick="MyBB.popupWindow('misc.php?action=imcenter&amp;imtype=msn&amp;uid={$uid}', 'imcenter', 450, 300);">{$memprofile['msn']}</a></td>
</tr>
</table>
</td>
<td><img src="{$theme['imgdir']}/pixel.gif" height="1" width="8" alt=""/></td>
<td width="50%" valign="top">
{$profilefields}{$socialsites}
{$signature}
<br/>
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
        <td class="thead">
        <strong></strong>
        </td>
    </tr>
    <tr>
        <td class="trow1"><A HREF="{$userfields['fid4']}" target="_blank"><img src="http://droidzone.in/romforum/images/donate.png" alt="Donate to me" /></A>
        </td>
    </tr>
</table>
{$modoptions}
{$adminoptions}
{$buddy_options}
</td>
</tr>
</table>
{$footer}
</body>
</html>

I have solved this.

First,
I added a custom profile field called Donation Link. It had an id of 4.

Then installed this plugin: PHP and Template Conditionals
This is because I do not want this field to display if user has not filled it.

Then, I had to modify the postbit template, under the span tag of "smalltext":
Home » Template Sets » Default Templates -> postbit_classic

If you use other template, you will have to modify that as well.

Added the following code:
<if !empty($post['fid3']) then>
Donation Link: <br /><a href="{$post['fid4']}"><img src="http://path_to_donation_link_image.png"></a><br />	
</if>

Between {$post['groupimage']} and {$post['useravatar']}

I had to add a few <br /> tags to get correct formatting.

Final code is like this:
<span class="smalltext">
			{$post['usertitle']}<br />
			{$post['userstars']}
			{$post['groupimage']} <br />
			<if !empty($post['fid3']) then>
Donation Link: <br /><a href="{$post['fid4']}"><img src="http://path_to_donation_link_image.png"></a>	<br />	
</if>	
			{$post['useravatar']}<br />
			{$post['user_details']}
		</span>


Activating it on my forum gives me this:
[Image: snapshot8.jpg]


I'm sure someone can come up with an easy plugin to do all this.
Solved! Smile