Hopefully this should work:
<?php
// This is just to make sure that the item is used through SMF, and people aren't accessing it directly
// Additionally, this is used elsewhere in SMF (in almost all the files)
if (!defined('SMF'))
die('Hacking attempt...');
class item_teddy extends itemTemplate
{
// When this function is called, you should set all the item's
// variables (see inside this example)
function getItemDetails() {
// The author's name
$this->authorName = 'brianjw';
// The author's email address
$this->authorEmail = 'brianjw@verizon.net';
// The author's website
$this->authorWeb = 'http://www.gamerzgarage.com';
// --- Values changeable from within the SMFShop admin panel ---
// The name of the item
$this->name = "Teddy Bear";
// The item's description
$this->desc = "Buy a Teddy Bear! You may also choose for your teddy bear to hang out in your pm box, so you can visit it.";
// The item's price
$this->price = 100;
// --- Unchageable values ---
// These values can not be changed when adding the item, they are stuck on what you set them to here.
// Whether inputs are required by this item. In this case, we get some inputs,
// so set this to 'true'.
$this->require_input = true;
// Set this to 'false' if the item is unusable. This is good for display
// items.
$this->can_use_item = true;
}
/*
* This function is called when the user tries to use the item.
* If your item needs any further user input then you can get that
* input here (eg. if it's a "Change username" item then you have
* to ask the user what they'd like to change their username to).
* Any text you return will get shown to the user (DON'T ECHO STUFF).
*/
function getUseInput()
{
return '<b>Name your teddy bear:</b> <input type="text" name="teddy_name" /><br /><b>Would you like your teddy bear to hang out with you in your pm box?</b> <input type="radio" name="teddy_pm" value="So I am glad you chose for me to be placed in your pm box (pm the admin to make it work)." />Yes -- <input type="radio" name="teddy_pm" value="So you chosed for me to not be placed in your pm box, so I will be sent back to the shop where another member will take me and care for me." />No';
}
// This is where all the fun begins. This function is called when
// the user actually uses the item. Return stuff, DON'T ECHO!
function onUse()
{
require_once('Sources/Subs-Post.php');
// Who is sending the IM
$pmfrom = array(
'id' => 0,
'name' => $_POST['teddy_name'],
'username' => $_POST['teddy_name']
);
// Who is receiving the IM
$pmto = array(
'to' => array($context['user']['id']),
'bcc' => array()
);
// The message subject
$subject = 'Subject';
// The actual message
$message = $_POST['teddy_pm'];
// Send the PM
sendpm($pmto, $subject, $message, 0, $pmfrom);
return '<b>' . $_POST['teddy_name'] . ' is speaking (your teddy bear):</b><br><br>Hello, my name is ' . $_POST['teddy_name'] . '!<br>I am your teddy bear and my favorite things to do are to be loved and cared for. ' . $_POST['teddy_pm'] . '';
}
}
?>