Author Topic: [SOLVED] PM the Admin when an item is used?  (Read 3291 times)

Offline lelele

[SOLVED] PM the Admin when an item is used?
« on: May 03, 2006, 10:38:47 am »
I asked the shop log question, but I see its not available at the moment.

Since its possible to pm member when an item is used for/against them, can I make it so everytime an item is used I get a pm too?

Thanks!

Offline majestic

Re: PM the Admin when an item is used?
« Reply #1 on: March 09, 2007, 01:29:10 am »
I also am looking for this. I'd like for when the person purchases a certain item, it sends a message to an account.

Offline Daniel15

Re: PM the Admin when an item is used?
« Reply #2 on: March 09, 2007, 09:39:15 am »
Quote
can I make it so everytime an item is used I get a pm too?
Sure, this shouldn't be too hard...
In Sources/shop/Shop-Inventory.php, find:
Code: (php) [Select]
// Create an instance of the item
eval('$temp = new item_' . $row['module'] . ';');
// Now, do the actual action!
$context['shop_buy_message'] = $temp->onUse();

Add before:
Code: (php) [Select]
// Who the IM will come from
$pmfrom = array(
'id' => $ID_MEMBER,
'name' => $context['user']['name'],
'username' => $context['user']['username']
);

// Who the IM is going to
$pmto = array(
'to' => array(1),
'bcc' => array()
);

// The subject of the message
$subject = $row['module'] . ' item used';
// The actual message contents
$message = 'The ' . $row['module'] . ' item has been used by ' . $context['user']['name'] . '. Full post data follows:' . "\n\n" . print_r($_POST, true);
// Now, send!
sendpm($pmto, $subject, $message, 0, $pmfrom);


Quote
I'd like for when the person purchases a certain item, it sends a message to an account.
Only for when one particular item is used?

Offline majestic

Re: PM the Admin when an item is used?
« Reply #3 on: March 13, 2007, 09:20:55 am »
yes, one particular item.

Offline Daniel15

Re: PM the Admin when an item is used?
« Reply #4 on: March 30, 2007, 07:31:48 pm »
In that case, it's probably best to edit the item itself.
If you open the item file (Sources/shop/items/[Name].php), you'll see an "onUse" section. Within this section, there is a "return" line (usually the last line of the onUse function). For example, the "Decrease Post Count" item has this:
Code: (php) [Select]
return 'Successfully decreased ' . $_POST['username'] . '\'s posts by ' . $item_info[1] . '!';

Right before this, add:
Code: (php) [Select]
global $context;
// Who the IM will come from
$pmfrom = array(
'id' => $ID_MEMBER,
'name' => $context['user']['name'],
'username' => $context['user']['username']
);

// Who the IM is going to
$pmto = array(
'to' => array(1),
'bcc' => array()
);

// The subject of the message
$subject = 'Item used';
// The actual message contents
$message = 'The item has been used by ' . $context['user']['name'] . '. Full post data follows:' . "\n\n" . print_r($_POST, true);
// Now, send!
sendpm($pmto, $subject, $message, 0, $pmfrom);


This should work :)

Offline Voldsom

Re: PM the Admin when an item is used?
« Reply #5 on: May 11, 2007, 10:23:46 am »
I try using these and I get one stupid error... also I dont know anything about MySQL...

Code: [Select]
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' mem.buddy_list) AS is_buddy, mem.is_activated,
(mem.ID_GROU
File: /homepages/23/d201797766/htdocs/Sources/Subs-Post.php
Line: 771

Php: 4.4.4
MySQL: 5.0

Also, I never modified this file.
« Last Edit: May 11, 2007, 10:32:10 am by Voldsom »

Offline Voldsom

Re: PM the Admin when an item is used?
« Reply #6 on: May 12, 2007, 05:40:15 am »
nvm, found the problem...