[How to] Send Auto PM in vb4.0
by
03 May 2010
In this article I am going to explain you how to send a PM with the Vbulletin 4.0.X it is based on this article Send PMs (automatically) written by Andreas PHP Code:
global $vbulletin;
Firstly it is to say, that you have to use the following three 3 lines if you are excluding that code in a class or function in a folder like /includes. PHP Code:
global $vbulletin;
Anyway lets continue: Before we can start setting anykind of information, we need a class with which we can work, this class is called "vB_DataManager_PM" it extends "vB_DataManager". (that is the reason why we had to require 2 classes from the /includes directory). "vB_DataManager_PM" works with the table: "pmtext" of your database. However we have to give her the registry, which is $vbulletin. So it should like this: PHP Code:
$pmSystem = new vB_DataManager_PM( $vbulletin );
from now on "$pmSystem" represents our class and we are finally able to set things up for sending a pm - so lets do it: Before I actually set the message and the title to the PM I want to make shure, that it is ok and that there are no unallowed things inside. PHP Code:
$pmSystem->verify_message( $pnText );
After that we do the actual PM set up: PHP Code:
$pmSystem->set('fromuserid', 1);
We say:
So lets send our PM or not? Before we actually send we can check if it successes by: PHP Code:
$pmSystem->pre_save()
So in the case shown above we say: if its possible and everything is fine, then: send it! ($pmSystem->save();) otherwise check if there are errors! PHP Code:
$pmSystem->errors
That is it. You should now be able to automatically send a message with the Vbulletin 4.0.X What can you do after reading this article? Have a look at the API http://members.vbulletin.com/api/vBulletin/vB_DataManager_PM.html I hope that I was able to help at least one person! Because it took me like three hours to figure this out!!! Enjoy, maybe you could write for what you are using automatic PMs All the best, Bjoern aka bpr |
Similar Mods
Miscellaneous Hacks Send Message Auto Reply | vBulletin 3.8 Add-ons |