Advertisement:

Allow Members to Collection Paypal Donations

Aloittaja Phphelp, elokuu 22, 2013, 06:08:39 IP

« edellinen - seuraava »

Phphelp

Since I recently took over an SMF Forum, I've been implementing my ideas, everyday I come up with new ones and I'm learning how SMF works from a code base.

So today, I decided to give my members the ability to collect paypal donations..

You can read about how it works here:

http://www.phphelp.com/forum/website-announcements/accept-paypal-donations-for-your-help!/msg72933/?topicseen#msg72933

I know the link will be inactive, but that's ok, you guys are smart.

In order to do this, I added a custom user field called "paypal", made it a text field.

Under

PHP Help Forum » Administration Center » Features and Options »
Profile Fields

Now the values of this field when populated gets stored in the SMF_Themes table, it took me a while to figure that out.

We only want the hosted payment ID number, because we can't use the code that paypal generates, because it's wrapped in <forms> tags.

So we have to convert it to a link.

So in the Display.template.php page, the code snippet below, you can see where I create the new paypal link with the members paypal button ID.

// Any custom fields to show as icons?
if (!empty($message['member']['custom_fields']))
{
$shown = false;
foreach ($message['member']['custom_fields'] as $custom)
{
if ($custom['placement'] != 1 || empty($custom['value']))
continue;
if (empty($shown))
{
$shown = true;
echo '
<li class="im_icons">
<ul>';
}
echo '
<li>';

if ($custom['colname'] === 'paypal')
{
echo '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=' . $custom['value'] . '"><img src="/images/paypaldonate.gif" border="0"/></a>';
}else{
echo $custom['value'];

}
echo '</li>';
}
if ($shown)
echo '
</ul>
</li>';
}


Once this is done, you can see the button show up, again use your skills to navigate to the page below.

http://www.phphelp.com/forum/general-php-help/loading-images-into-css-modal/

You can see the user TopCoder has a paypal donate button.

So what do you all think? Is this cool, should we turn it into a mod?

Henry
www.unlocktheinbox.com
www.phphelp.com/forum/

Matthew K.

There's an existing modification called "Buy Me a Drink" which allows people to donate to individual members...

You still could turn it into a mod if you wanted to though :)

Phphelp

Thanks Labradoodle-360,

   I reviewed the mod and changed the one I made to do it based of email ID, it's much cleaner that way.


Advertisement: