Author Topic: [SOLVED] Change Custom Title... To Something Specific  (Read 2078 times)

Offline Emperium

[SOLVED] Change Custom Title... To Something Specific
« on: February 14, 2008, 07:32:34 am »
I know there's the change title item, but I don't wan't to give my members the choice of changing the custom title themselves. For example I wan't them to buy a specific Custom Title.
Example: Purchase Custom Title: I pwn teh world! - 1000 Credits
So they pay 1000 Credits and they will have they're current Custom Title changed to "I pwn teh world!" or if they haven't had a custom title before this gets added to their profile.

(Of course I'll be sure the members permissions so that they cannot change their own title willingly.)

I also want to make sure that the member cannot buy a certain title until they have another title item in their inventory.
For example to buy Custom Title: "Level 7 - Lucky 7", a member will have to have 6 other Custom titles purchased, 1 through 6, to be able to purchase the Level 7 title.

Offline Daniel15

Re: Change Custom Title... To Something Specific
« Reply #1 on: February 15, 2008, 06:38:01 am »
Quote
For example I wan't them to buy a specific Custom Title.
Sure, that's easy :). there's no item in SMFShop to do that, but you can easily add one. Save this:
Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_ChangeTitle extends itemTemplate
{
function getItemDetails()
{
$this->authorName 'Daniel15';
$this->authorWeb 'http://www.dansoftaustralia.net/';
$this->authorEmail 'dansoft@dansoftaustralia.net';

$this->name 'Change User Title to set value';
$this->desc 'Change your user title to a value specified by the admin';
$this->price 50;

$this->require_input false;
}

function getAddInput()
{
global $item_info;
if ($item_info[1] == 0)
$item_info[1] = '';

return 'Custom title to use: <input name="info1" size="50" value="' $item_info[1] . '" />';
}

function onUse()
{
global $item_info$context$func;

updateMemberData($context['user']['id'], array('usertitle' => '"' $item_info[1] . '"'));
return 'Successfully changed your user title to ' $item_info[1];
}

}

?>

As "ChangeTitle.php" in your SMF Sources/Shop/items/ directory. Then, when you add the item (via Add/Edit/Delete Items in the admin panel), it'll prompt you to enter in a custom title you'd like the item to use :)



Offline Emperium

Re: [SOLVED] Change Custom Title... To Something Specific
« Reply #2 on: February 15, 2008, 06:51:35 am »
Awesome, thanks so much Daniel15!!!

Works well and absolutely love it. But is there a way to prevent a member from purchasing an item without having other specific items in their inventory?