i just noticed the "emailadmin" item which is almost what i'm looking for... i was just wondering if someone might be able to help me modify it...
this is the original code
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
| (c) 2005 DanSoft Australia |
| http://www.dansoftaus.uni.cc/ |
\**********************************************/
//File: EmailAdmin.php
// Email the admin item
//VERSION: 2.0 (Build 8)
//DATE: 26th December 2005
class item_EmailAdmin extends itemTemplate {
function getItemDetails() {
$this->name = "Send Email to Admin v2";
$this->desc = "Send off an email to the admin. A good use for this (for a web host) is an 'Add 100MB of Webspace to your hosting account'";
$this->price = 10;
}
function getAddInput() {
return 'Your email address: <input type="text" name="info1" size="50"><br>
Subject of message: <input type="text" name="info2" size="50"><br>
Additional fields needed:<br>
<textarea name="info3" rows="6" cols="40">
Web Hosting Username: <input type="text" name="host_user">
</textarea><br>
Message to send:<br>
<textarea name="info4" rows="10" cols="80">
100MB Extra webspace has been bought from the Forum Shop by user {$_POST["host_user"]}. Please add it to his/her account
--Shop Mailer
</textarea><br>
<b>NOTE:</b> The additional fields will be filled in by the user when they use the item.
To use one of your additional fields in either the message or subject, use the {$_POST["varname"]}
format, where "varname" is the name of the field (see the above dummy data for an example)';
}
function getUseInput() {
global $item_info;
//the 'additional fields needed' entered during item setup
return $item_info[3];
}
function onUse() {
global $item_info;
$to = $item_info[1];
$subject = $item_info[2];
$message = $item_info[4];
//Hack put in place to allow $_POST and $_GET vars in the $message var
//--daniel15, 4 Septemeber 2005 2:15PM
foreach ($_POST as $postKey => $postVar){
$message = str_replace('{$_POST["'.$postKey.'"]}', $postVar, $message);
// $message = str_replace("{$_POST['".$postKey."']}", $postVar, $message);
}
foreach ($_GET as $getKey => $getVar){
$message = str_replace('{$_GET["'.$getKey.'"]}', $getVar, $message);
// $message = str_replace("{$_GET['".$getKey."']}", $getVar, $message);
}
mail($to, $subject, $message) or die("Error sending message to admin! Please inform the Admin of this error. This item will still be available in your inventory.");
return "Message sent to admin!";
}
}
?>
i would like something much simplier, instead of requiring the user to put in a name like the above does, is there any possible way of taking out the user input altogether and instead using $ID_member or whatever the code is for the username/display name and just shoving that directly in the email that gets sent so that you do not require user input whatsoever...
and in saying that is it also possible to make the message
100MB Extra webspace has been bought from the Forum Shop by user {$_POST["host_user"]}. Please add it to his/her account
--Shop Mailer
have the username as a link to their profile like all SMF emails usually have.
Of course it would be much simplier i think if we skipped the email and instead send a PM but i really have no idea how to do that.
all i have worked out how to do is stop the item from dissapearing out of the users inventory... by changing
return "Message sent to admin!";
to
die ("Message sent to admin!");
however that is a bit messy and requires the user to then click the back button and then refresh but i know no other way