warmarks
07-30-2012, 10:59 AM
Hi,
Thanks for the great support and codes.
I have this code from another thread which is working great adding new account
automatically.
<?php
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
define('CWD', '/home--path');
require_once(CWD . '/includes/init.php');
// Data from Form Submision for VB
$username = $_GET["username"];
$password = $_GET["password"];
$email = $_GET["email"];
$usrgrp = $_GET["usergroupid"];
$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$newuser->set('username', $username);
$newuser->set('email', $email);
$newuser->set('password', $password);
$newuser->set('usergroupid', $usrgrp);
$newuser->pre_save();
if(empty($newuser->errors)){
$newuserid = $newuser->save();
echo "congratulations you are added <br>
Please note: <br>your username: <b>".$username."</b>
<br>Your Passowrd: <b>".$password."</b>";
}
//assuming errors[0] is email already exist
//and errors[1] is username already exist
elseif(!empty($newuser->errors[0])){
//update usergroup to $usrgrp
echo "email already in use.. please login here";}
elseif(empty($newuser->errors[0] && !empty($newuser->errors[1]))
{
echo "username already taken by some other
user please try with new username";
}
I just stuck with error handling..
i.e. there could be two types of errors..
1. Email is already in use.. that means this user is already registered !
in that case i want to add him to additional usergroup
2. Username already exists... but Email does not in use,
that means user need to choose some other USERNAME,
in that take to form again to ask to choose different username..
I am stuck on #1 above.. as in errors
$newuser->errors
how can i make sure that if
$newuser->errors[0] is error case #1 or #2
$newuser->errors[1] is error case #1 or #2
Ideally it would be great if i could have
$newuser->errors['email'] that means email already exists but not username, error case #1 above.
$newuser->errors['username'] that means username already exists error case #2 above.
Maybe i am approaching it wrong, i am very new to VBulletin.. hope you can guide me
Thanks
Thanks for the great support and codes.
I have this code from another thread which is working great adding new account
automatically.
<?php
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
define('CWD', '/home--path');
require_once(CWD . '/includes/init.php');
// Data from Form Submision for VB
$username = $_GET["username"];
$password = $_GET["password"];
$email = $_GET["email"];
$usrgrp = $_GET["usergroupid"];
$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$newuser->set('username', $username);
$newuser->set('email', $email);
$newuser->set('password', $password);
$newuser->set('usergroupid', $usrgrp);
$newuser->pre_save();
if(empty($newuser->errors)){
$newuserid = $newuser->save();
echo "congratulations you are added <br>
Please note: <br>your username: <b>".$username."</b>
<br>Your Passowrd: <b>".$password."</b>";
}
//assuming errors[0] is email already exist
//and errors[1] is username already exist
elseif(!empty($newuser->errors[0])){
//update usergroup to $usrgrp
echo "email already in use.. please login here";}
elseif(empty($newuser->errors[0] && !empty($newuser->errors[1]))
{
echo "username already taken by some other
user please try with new username";
}
I just stuck with error handling..
i.e. there could be two types of errors..
1. Email is already in use.. that means this user is already registered !
in that case i want to add him to additional usergroup
2. Username already exists... but Email does not in use,
that means user need to choose some other USERNAME,
in that take to form again to ask to choose different username..
I am stuck on #1 above.. as in errors
$newuser->errors
how can i make sure that if
$newuser->errors[0] is error case #1 or #2
$newuser->errors[1] is error case #1 or #2
Ideally it would be great if i could have
$newuser->errors['email'] that means email already exists but not username, error case #1 above.
$newuser->errors['username'] that means username already exists error case #2 above.
Maybe i am approaching it wrong, i am very new to VBulletin.. hope you can guide me
Thanks