Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - celadore

Pages: [1]
Items / New Item: Add membergroup
« on: March 07, 2007, 09:17:30 am »
Save this as AddMembergroup.php under shop items.

I wanted to allow users to purchase additional membergroups.  The only solutions I found were the ChangeMembergroup in default SMF 3.0 and the BuyMembergroup by Chad (which didn;t work for me).  So I used both these to create a AddMembergroup item (I have only been using SMFShop for 20 minutes, but it appears to work for me).

What the Buyer gets:  The member who uses this item will have himself ADDED to the 1 membergroup for which the item was set-up for.  It will leave his primary membergroup unchanged.  The user does NOT get to choose which membergroup he wants to be added to NOR is he assigned to a random one.

Code: [Select]
//File: AddMembergroup.php
//      Item

//DATE: Mar 07, 2007
//Author Taj

class item_AddMembergroup extends itemTemplate {
getItemDetails() {
$this->authorName "Taj";

$this->authorWeb "";

$this->authorEmail "";

$this->name "Add Membergroup";
$this->desc "Allows you to add yourself to a membergroup!";
$this->price 1;

$this->require_input false;
$this->can_use_item true;

getAddInput() {
global $db_prefix;

$selectBox '<select name="info1">';

// Get all non post-based membergroups
$result db_query("SELECT ID_GROUP, groupName
WHERE minPosts = -1"

// For each membergroup, add it to the list
while ($row mysql_fetch_assoc($result)) {
$selectBox .= "<option value='{$row['ID_GROUP']}'>{$row['groupName']}</option>";

$selectBox .= "</select>";
"Membergroup: ".$selectBox;

onUse() {

$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'].", ".$item_info[1];
} else {
$additionalGroups['additionalGroups'] = $item_info[1];

$result db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'

"You have joined new membergroup {$item_info[1]}!!";

Pages: [1]