Author Topic: Could someone edit Chad's Membergroup item?  (Read 2100 times)

Offline E-boy

Could someone edit Chad's Membergroup item?
« on: October 25, 2009, 08:47:07 am »
Right now you can only buy your OWN membergroup. But I'd like someone to edit the item, so that you need to input a username. Then the user you inputted 'buys' the new membergroup, not you.

Oh yeah, I forgot the code:

Code: [Select]
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|        |

//File: BuyMembergroup.php
//      Item

//VERSION: 1.0 (Build 1)
//DATE: Oct 22, 2006
//Author Chad

class item_BuyMembergroup extends itemTemplate {
getItemDetails() {
$this->authorName "Chad";

$this->authorWeb "";

$this->authorEmail "";
$this->name "Buy Membergroup";
$this->desc "Allows you to buy your way into a membergroup!";
$this->price 250;

$this->require_input true;
$this->can_use_item true;
getAddInput() {

$result db_query("SELECT groupName 
$row mysql_fetch_array($resultMYSQL_ASSOC);

while (
$row mysql_fetch_array($resultMYSQL_NUM)) {
$groups.=("<OPTION id='x{$i}' value='{$row[0]}'>{$row[0]}");
"Which Membergroup ID do you want to grant users access to?: <SELECT name='info1'>{$groups}</SELECT>";


onUse() {

/////////////NOTICE  change the following ID or your item will fail.
$shophistoryID=0;//Set this to 0 if you don't have a shop history forum

//Begin Shop history
if ($shophistoryID) {
$sourcedir '/Subs-Post.php');
$topicOptions['board'] = $shophistoryID//SHOP history forum
$topicOptions['id']=0//NEW topic
$msgOptions['subject'] = "I just bought my way into the {$item_info[1]} membergroup!"//Subject
$msgOptions['body'] = "Yep!"
$posterOptions['id']=$ID_MEMBER//Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function
//End Shop history

$groupID=mysql_fetch_array(db_query("SELECT `ID_GROUP` FROM {$db_prefix}membergroups WHERE groupName = '{$item_info[1]}'"__FILE____LINE__),MYSQL_ASSOC);
$additionalGroups mysql_fetch_array(db_query("SELECT `additionalGroups` FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__),MYSQL_ASSOC);

$additionalGroups['additionalGroups']) {
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].", ".$groupID['ID_GROUP'];
} else {
$additionalGroups['additionalGroups'] = $groupID['ID_GROUP'];
$result db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'
                 WHERE ID_MEMBER=

"You're in the new group, {$item_info[1]}!!";
« Last Edit: October 25, 2009, 08:51:12 am by E-boy »

Offline bigjoe11a

Re: Could someone edit Chad's Membergroup item?
« Reply #1 on: March 16, 2011, 11:01:47 pm »
Hi! E-Boy. I'm new here and I'm not new to PHP. I wanted to see if you got this working. I can't see any reason for adding this option since SMF comes with it's own Paid Subscriptions build right in.

I was checking you code and I see some errors that just won't work. If your wanted to ask the user for the name of the person.

Code: [Select]
function getUseInput()
return 'Members Name: <input type="text" name="memname" />';

The other error that I saw.

//Your setting $shophistoryID to 0. // This is wrong
$shophistoryID=0;//Set this to 0 if you don't have a shop history forum

//here your asking for a true or false statement. so the 1st statement is wrong
if ($shophistoryID) {

I do know that SMF RC5 has the paid subscription built in. Your better off to use that.
and it wouldn't be a very good idea to scroll there the list of member groups too. Because New Users could select the Admin Member Group. Then they could do any thing to your board and post any where they wanted. They could really screw you on that.

I think the idea would be to create an array of the group members you wanted users to buy.

$memgroups = array();
$memgroups[0] = 'Group Name 1';
$memgroups[1] = 'Group Name 2';

Then display them
foreach($val as $memgroup)
return ' '.$val.'<br />';

Oh and one more thing. You can't use 'echo' in your code.

Serving Gamers from around the world