Quote:
Originally Posted by KGodel
Hey guys.
I was wondering if there was a PM function in vB or if it would be difficult to build one. We have several custom systems that award users points for certain things and we'd like to be able to generate PMs with that information and send it to those users. Thanks!
|
There is, lemme dig out some code I've used in the past.
PHP Code:
$message = ""; // pm body
$title = ""; // pm title
$fromid = ""; // userid of pm sender
$toid = ""; // userid to send pm to
$fromuser = fetch_userinfo($fromid);
$tuser = fetch_userinfo($toid);
$uname = $tuser['username'];
$idu = $tuser['userid'];
$to = "$uname";
$id = "$idu";
$pm =& datamanager_init('PM', $vbulletin, ERRTYPE_STANDARD);
$pm->set('fromuserid', $fromuser['userid']);
$pm->set('fromusername', $fromuser['username']);
$pm->set('title', $title);
$pm->set('message', $message);
$pm->set('iconid', 1);
$pm->set('showsignature', 1);
$pm->set('allowsmilie', 1);
$pm->set_recipients($to, $fromuser['permissions']);
$pm->set('dateline', TIMENOW);
$pm->save();
It's a little messy, but it gets the job done. It could be easily implemented into existing code by a developer.