PDA

View Full Version : Autofill PM from form.


noj75
08-12-2008, 07:56 AM
Hi guys,

I was just wondering if any of you coders out there would know how to accomplich this:

If I have an external page and want a member to send a different member a PM I can achieve it like this using chdir() :



// I have done some query here.

$id = $row['userid'];
$name = $row['username'];

echo '<a href="../forums/private.php?do=newpm&amp;u='.$id.'">Send '. $name.' A PM</a>';




Thats all fine and dandy. However, if I wanted to send a PM to the user that will autofill the PM text area in private.php from a text area in my external page how would I do it? Is this possible to achive without modifying vB. i.e is there a way of using $_POST and the url to achieve this?

Any ideas would be very much appreciated.

Kind regards

RLShare
08-12-2008, 08:02 AM
If your forcing the user to send a message to a certain user and want to fill in the text area for them. Why not use the PM Datamanager in your script to send a PM straight from your script?


$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);

$pmdm->set_info('savecopy', 0);
//^^^Set to 1 to save a copy in the senders outbox
$pmdm->set_info('receipt', 0);
$pmdm->set_info('cantrackpm', 0);
$pmdm->set_info('parentpmid', 0);
$pmdm->set_info('forward', 0);
$pmdm->set_info('bccrecipients', '');
$pmdm->overridequota = true;
$title="Title.";
$message="This is a message YOU CAN ADD BBCODE";
$iconid=0;
$pmdm->set('fromuserid', $userid);
$pmdm->set('fromusername', $username;
$pmdm->setr('title', $title);
$pmdm->set_recipients("USERNAME OF RECIPIENT", $permissions, 'cc');
// ^^username of the person/persons to send PM to
$pmdm->set_recipients('', $permissions, 'bcc');
$pmdm->setr('message', $message);
$pmdm->setr('iconid', $iconid);
$pmdm->set('dateline', TIMENOW);
$pmdm->setr('showsignature', $iconid);
$pmdm->set('allowsmilie', $iconid );
$pmdm->save();

noj75
08-12-2008, 08:06 AM
Thanks for you extremely quick reply.

How would I implement the script above? Sorry, not a genius at PHP but know just enough to get me by.

Could you, by any chance, give me a quick example of how to integrate it?

Very much appreciated RLShare.

RLShare
08-12-2008, 06:34 PM
As long as you have 'global.php' included you would do it just as I posted it where ever you wanted to send a pm.

You would need to change the $title , $message , fromuserid , fromusername and Set recipients at the very least.

Everything else is optional for you to change if you want and are pretty self explanatory, they all coinside with options that are available when you send a PM from the private message center in VB.