The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Add new Users (automatically)
As this is a common request for integration purposes, I thought I should write up another HowTo If you want to add a new user to the vBulletin database, you can use Class vB_Datamanager_User. This Calss does make sure that everything is OK, it will also take care of the default registration options. Example PHP Code:
PHP Code:
If everything is OK PHP Code:
You can also set many other info too:
Besides that, you can also set the options Bitfield (Receive Admin PMs, etc.) PHP Code:
Value must be 0 or 1 (false or true), depending if you want to set the option or not. If the Options are not set, the Default Registration Options/Board Default Options will be used. Important Notice It is assumed that you are using this code from 'within' vBulletin, eg with the vBulletin backend loaded. If this is not the case, you must include smth. like the following code in global context: PHP Code:
This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent. |
#152
|
|||
|
|||
Looking for an updated version of this script for 4.1.1
Am getting this error: Code:
Fatal error: Call to undefined function fetch_phrase() in /home2/hatnohat/public_html/forum/includes/functions.php on line 3456 This works for me. add_user.php (custom API) PHP Code:
|
#153
|
||||
|
||||
Quote:
In the meantime you can simply add PHP Code:
|
#154
|
|||
|
|||
I used this code and everything was working fine. Users got added, but when they tried to login, they got this message:
Code:
You have been banned for the following reason: No reason was specified. Date the ban will be lifted: Never |
#155
|
|||
|
|||
Nack, make sure the user group that your user is being created under is being defined. If you aren't in the right group then they show as being banned. Hope this helps.
|
#156
|
||||
|
||||
I keep getting a fatal error:Fatal error:
Code:
Fatal error: Registry object is not an object in [path]/includes/class_dm.php on line 205 Main Code Code:
<?php
mysql_connect($DBhost, $DBuser, $DBpass) or die(mysql_error());
mysql_select_db($DBname) or die(mysql_error());
$RegAllowArray = mysql_query("SELECT * FROM setting WHERE varname = 'allowregistration'") or die(mysql_error());
$RegAllow = mysql_fetch_array($RegAllowArray);
$CountUserArray = mysql_query("SELECT COUNT(*) FROM user") or die(mysql_error());
$CountUser = mysql_num_rows($CountUserArray);
if($CountUser < 50)
{
if($RegAllow['value'] != 0)
{
function register_in_vb($username, $password, $email, $day, $month, $year)
{
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 0);
define('SKIP_USERINFO', 1);
require_once('/home/shininga/public_html/divineshadowsonline/forum/includes/init.php');
require_once('/home/shininga/public_html/divineshadowsonline/forum/includes/functions_misc.php');
$registry = $vbulletin;
unset($vbulletin);
$vbDb = $registry->db;
//declare as global vbulletin's registry and db objects
global $vbulletin,$db;
$vbulletin = $registry;
//backup the original $db object (new!!)
$backupdb = $db;
$db = $vbDb;
$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$newuser->set('username', $username);
$newuser->set('email', $email);
$newuser->set('password', $password);
$newuser->set('usergroupid', 2);
$newuser->set('displaygroupid', 2);
$newuser->set('birthday', array($month, $day, $year));
$newuser->pre_save();
if(empty($newuser->errors)){
$db = $backupdb;
echo 1;
return $newuser->save();
}else{
$db = $backupdb;
echo 0;
print_r( $newuser->errors);
include("/home/shininga/public_html/divineshadowsonline/includes/register-form.php");
}
}
if(!$logged_in) {
if(isset($_POST['username']))
{
$key = $_POST['key'];
$username = $_POST['username'];
$password = $_POST['password'];
$confirmpass = $_POST['confirmpass'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$email = $_POST['email'];
$tos = $_POST['tos'];
include("/home/shininga/public_html/divineshadowsonline/includes/register-functions.php");
$newuserid = register_in_vb($username, $password, $email, $day, $month, $year);
} else if(!isset($_POST['username'])) {
include("/home/shininga/public_html/divineshadowsonline/includes/register-form.php");
}
} else {
echo "<h4><center><b>You are already logged in!</b></center></h4>";
}
} else {
echo "<center>Registration Are Currently Disabled</center>";
}
} else {
echo "<center>Registration Are Currently Disabled</center>";
}
mysql_close();
?>
|
#157
|
|||
|
|||
|
#158
|
||||
|
||||
Quote:
Code:
ob_start(); $curdir = getcwd (); chdir('/home/shininga/public_html/divineshadowsonline/forum/'); require_once('./global.php'); $phrasegroups = array(); $headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude); chdir ($curdir); |
#159
|
|||
|
|||
What if you change your header to this:
Code:
require_once('/home/shininga/public_html/divineshadowsonline/forum/'); $phrasegroups = array(); $headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude); |
#160
|
||||
|
||||
Doesn't work. I had to change the directory before because I had to call a lot of the internal features within vB. I'm pulling user information and login checks of all types all over the site. If i just include the global instead of redefining the directory I get this error:
Code:
Warning: require_once(./includes/class_bootstrap.php) [function.require-once]: failed to open stream: No such file or directory in /home/shininga/public_html/divineshadowsonline/forum/global.php on line 15 Fatal error: require_once() [function.require]: Failed opening required './includes/class_bootstrap.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/shininga/public_html/divineshadowsonline/forum/global.php on line 15 |
#161
|
|||
|
|||
Vbulletin 4.x user registration version:
Code:
define('THIS_SCRIPT', 'reguser.php');
require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_user.php');
$userdm = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);
$pass1 = $_REQUEST["pw1"];
$pass2 = $_REQUEST["pw2"];
if ($pass1 == $pass2)
$passwd = $pass1;
else
exit;
$userdm->set('username', $_REQUEST["user"]);
$userdm->set('email', $_REQUEST["email"]);
$userdm->set('password', $passwd);
$userdm->set('usergroupid',2);
#If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
if (count($userdm->errors))
{
echo "<pre>";
var_dump($userdm->errors);
echo "</pre>";
} else {
# If everything is OK
$newuserid = $userdm->save();
echo $newuserid."<br>Done.";
}
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|