I've take the necessary code out of private.php, put it into functions and saved it as includes/functions_pm.php.
It does look like that:
[php]
function send_pm($pm, $sender, $errors) {
// Code from private.php with some modifications to meet new environment goes here
}
Now if you want to send a PM just do the following
PHP Code:
require_once('./includes/functions_pm.php');
$pm = array('title' => 'Some test', 'message' => 'Some foobar text', 'recipients' => 'foobar_user');
$sender = array('userid' => 1234, 'username' => 'sender');
send_pm($pm, $sender, $errors);
if (is_array($errors))
// Do some error-handling
If the sender should be the person calling the script yu can just ust $bbuserinfo insteadn of creating your own array ($sender).
You can also set more options (savecopy, title, disablesmilies, signature, receipt, pmid) in array $sender.
Unfortunately the vB license does not allow me to publish the whole file, otherwise I would attach it here.
The necessary code from private.php starts after
PHP Code:
// *************************************************************
// PROCESS THE MESSAGE AND INSERT IT INTO THE DATABASE
else
{
Maybe this does help to get you started.