German person living in London, writing some crazy php codes and usually provide my knowledge to others over the internet by writing or recording tutorials
//"send" pn
if ( $pmSystem->pre_save() === false )
{
if ($pmSystem->errors) {
return $pmSystem->errors;
}
}
else
{
$pmSystem->save();
}
That's it basically. Lets go through those lines:
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;
require_once(DIR . "/includes/class_dm.php");
require_once(DIR . "/includes/class_dm_pm.php");
Those will provide you the usage of the whole system. I assume, that you dont need those lines if you already included the global.php! - But I am not that shure maybe somebody could confirm that.
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.
The name of the sender is "PM Bot" - it doesn't have to be the name of the user with the id
We set up the title!
After that the message
Now we need a date time when it was sent
The iconid is not required, in this case it represents the red one with the ! symbol
Who will get the message, you can provide more recipients by doing it as followed "user1;user2;user3;user4;..." Important is just the ; which identifies the list and another user
So lets send our PM or not?
Before we actually send we can check if it successes by:
PHP Code:
$pmSystem->pre_save()
This will return "true" or "false" - obviously true represents that it will be successfull and false it wont!
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
if there are errors, then print them.
That is it. You should now be able to automatically send a message with the Vbulletin 4.0.X
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
Hello everyone, I have been trying to get my code to work but every time I run this file all I get is internal server errors everytime. What am I doing wrong?? Here is my php file:
PHP Code:
<?php
global $vbulletin;
require_once(DIR . "/includes/class_dm.php"); require_once(DIR . "/includes/class_dm_pm.php"); //pm system $pmSystem = new vB_DataManager_PM( $vbulletin );
//pm Titel / Text $pnTitel = "Your Title for the PM"; $pnText = "This is pm which was created automatically. Please do not reply to this pm.";