Can someone provide an example that actually works and can be tested for clarity of how to use the Data Manager API. The examples that are in the manual are sniplets that are missing elements that will actually allow them to run without error. Is there an example of some type of simple hello world! type of code that can actually be tested to see how it works.
The steps provided at https://www.vbulletin.com/docs/html/...er_programming says its assumed that we are within the vBulletin environment already. Does this mean that special includes are already attached to the top of the file? Or does it means that we are running the script from the route directory, the api directory, the includes directory, or the core/includes directory.
I have tried to run the script from all the above directories and get the following error:
I have also tried a number of the snippets that are included in the manual.
This is a particular code that I have tried to get to run (insert a user):
(An example from: https://www.vbulletin.com/docs/html/...er_programming)
-- L. James
--
L. D. James
[email protected]
www.apollo3.com/~ljames
The steps provided at https://www.vbulletin.com/docs/html/...er_programming says its assumed that we are within the vBulletin environment already. Does this mean that special includes are already attached to the top of the file? Or does it means that we are running the script from the route directory, the api directory, the includes directory, or the core/includes directory.
I have tried to run the script from all the above directories and get the following error:
PHP Code:
PHP Fatal error: Uncaught Error: Call to undefined function datamanager_init() in /home/web/forum3/www/myinsertuser.php:6
Stack trace:
#0 {main}
thrown in /home/web/forum3/www/myinsertuser.php on line 6
This is a particular code that I have tried to get to run (insert a user):
(An example from: https://www.vbulletin.com/docs/html/...er_programming)
PHP Code:
// init user datamanager class
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
// check for matching email addresses
if ($vbulletin->GPC['email'] != $vbulletin->GPC['emailconfirm'])
{
$userdata->error('emailmismatch');
}
// set email
$userdata->set('email', $vbulletin->GPC['email']);
$userdata->set('username', $vbulletin->GPC['username']);
// check referrer
if ($vbulletin->GPC['referrername'] AND !$vbulletin->userinfo['userid'])
{
$userdata->set('referrerid', $vbulletin->GPC['referrername']);
}
// Set specified options
if (!empty($vbulletin->GPC['options']))
{
foreach ($vbulletin->GPC['options'] AS $optionname => $onoff)
{
$userdata->set_bitfield('options', $optionname, $onoff);
}
}
// ... additional data setting ...
$userdata->pre_save();
// check for errors
if (!empty($userdata->errors))
{
$errorlist = '';
foreach ($userdata->errors AS $index => $error)
{
$errorlist .= "<li>$error</li>";
}
// ... additional code; $errorlist is outputted to the user
}
else
{
// save the data
$vbulletin->userinfo['userid']
= $userid
= $userdata->save();
// ... additional processing code
}
--
L. D. James
[email protected]
www.apollo3.com/~ljames
Comment