Have you ever wanted to create a hack that'll private message users when they reach a certain point in the script?
For instance say you wanted to private message user "abc" when he or she reaches the end of the form.
The first thing you'll need to do is require "includes/class_dm.php" along with "global.php".
I have put the Private Message API into a function. I decided to do this in my own script due to the repetiveness.
PHP Code:
function pm_api($fromuserid, $fromusername, $title, $message, $recipients)
{
global $vbulletin, $botpermissions;
Now that you have the function you'll need to create a method to use with it.
Let's say you owned a auction type forum and wanted to private message an user after they've entered their product's information into the form.
PHP Code:
$fromuserid = 1;
$fromusername = "Auctioneer";
$title = "Your Entry is Being Reviewed";
$message = "Hello ".$vbulletin->userinfo['username'].",
We are now reviewing your entry.";
$recipients = $vbulletin->userinfo['username'];
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
//create a function for the Private Message API.
function pm_api($fromuserid, $fromusername, $title, $message, $recipients)
{
global $vbulletin, $botpermissions;
$fromuserid = 1;
$fromusername = "Auctioneer";
$title = "Your Entry is Being Reviewed";
$message = "Hello ".$vbulletin->userinfo['username'].",
We are now reviewing your entry.";
$recipients = $vbulletin->userinfo['username'];
nope, i had a save ^^; its actchually still puzzling, because all you had wa puting it in a function, and adding return and unset.... which shouldent have made any differance! but, whats with the global at the top? i never had that...
(my guess is that its because it is in a function)
nope, i had a save ^^; its actchually still puzzling, because all you had wa puting it in a function, and adding return and unset.... which shouldent have made any differance! but, whats with the global at the top? i never had that...
(my guess is that its because it is in a function)
The reason I globalize "$vbulletin" and "$botpermissions" is to carry the value of those two variables into the function (I think that's how to explain it).
If I haven't have globalized those two the API would be rendered useless.
Quote:
Originally Posted by JumpD
No need to return a value.
PHP Code:
unset($pmdm);
return $pmdm;
I can remove those two tidbits?
It's been a while but I think I tried to use the function without returning the value and it didn't work. I could be wrong though.