vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Add new Users (automatically) (https://vborg.vbsupport.ru/showthread.php?t=82836)

tomypro 04-10-2009 09:42 PM

Hi,

Im using ArbuZz's code base and its working create; i am using it as well as a SSO bridge between my app and the integrated vbulletin board.

Once thing i would like to achieve is that as soon as I trigger the login call for a user through my busines logic not only the session cookie is set but that that partiular users appears as online within vbulletin as well.

Is this something that can be achieved through the Data API as well?

//Thomas

nessur 05-04-2009 07:50 PM

Thank you, and thank you! This fixed my problem.

Quote:

Originally Posted by harty83 (Post 1676059)
Just as a FYI, the first line (global $vbulletin) is not necessary. That was overlooked on my part. The full code that got it working is

Code:

               
//load the vbulletin framework
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
define('CWD', 'path/to/vbulletin/forum'));

require_once(CWD . './includes/init.php');

 //work around to make global vbulletin stick
$registry = $vbulletin;
unset($vbulletin);
$vbDb = $registry->db;
//declare as global vbulletin's registry and db objects
global $vbulletin,$db;
$vbulletin = $registry;
//vbulletin db object which is needed for vbulletin's project tools addon
$db = $vbDb;

Thanks!
Alan


galt 05-12-2009 12:33 PM

After hours of hacking at this, I am once again stuck. I have included this code in my CMS.

Code:

if ($vbswitch == 'Y') {
        chdir('./forums');
        define('THIS_SCRIPT','pg_usermgmt2.php');
//        define('VB_AREA', 'Forum');
        require_once("global.php");
        require_once("./includes/class_dm.php");
        require_once("./includes/class_dm_user.php");
        chdir('../');
};


and lower down
Code:

if ($vbswitch == 'Y') {

       
        $newuser = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);
//        $newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
        $newuser->set('username', $UserName);
        $newuser->set('email', $EMail);
        $newuser->set('password', $Password);
        $newuser->set('usergroupid', 2);
        if ($newuser->errors) {
                echo $newuser->errors;
                }
        else {
                $newuserid = $newuser->save();
        };

When the second block of code executes, I get the error:

Database object is not an object in [path]/includes/class_dm.php on line 172

I am stumped. I tried adding the global hack referenced a few posts back, and it did nothing for me. I am spending more time trying to get VB rgistration integrated that I am writing my entire CMS!!! ARRRGGGHHH !!!!! I would gladly pay someone to do this for me if I could find them.
**********************************
Nevermind. I just wrote my own object. WAY faster and easier.

php-resource.de 05-13-2009 07:54 AM

Quote:

Originally Posted by galt (Post 1809352)
After hours of hacking at this, I am once again stuck. I have included this code in my CMS.

Code:

if ($vbswitch == 'Y') {
        chdir('./forums');
        define('THIS_SCRIPT','pg_usermgmt2.php');
//        define('VB_AREA', 'Forum');
        require_once("global.php");
        require_once("./includes/class_dm.php");
        require_once("./includes/class_dm_user.php");
        chdir('../');
};


and lower down
Code:

if ($vbswitch == 'Y') {

       
        $newuser = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);
//        $newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
        $newuser->set('username', $UserName);
        $newuser->set('email', $EMail);
        $newuser->set('password', $Password);
        $newuser->set('usergroupid', 2);
        if ($newuser->errors) {
                echo $newuser->errors;
                }
        else {
                $newuserid = $newuser->save();
        };

When the second block of code executes, I get the error:

Database object is not an object in [path]/includes/class_dm.php on line 172

I am stumped. I tried adding the global hack referenced a few posts back, and it did nothing for me. I am spending more time trying to get VB rgistration integrated that I am writing my entire CMS!!! ARRRGGGHHH !!!!! I would gladly pay someone to do this for me if I could find them.
**********************************
Nevermind. I just wrote my own object. WAY faster and easier.

I guess you are using the global $db within your CMS.
Try the following workaround:
PHP Code:

  $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;

  
/*
   * Your code here
   */

  // Restore your $db object (new!!)
  
$db $backupdb


galt 05-13-2009 08:43 AM

Thanks. I had already tried that, then removed it. That was my reference to "the global hack referenced a few posts back". It did not help. At this point I am creating a new user and maintaining critical fields managed with some SQL directly into the vB database. As soon as I figure out cookies and login, I am good to go. That is, until vB changes the user scheme, at which time i will have an ongoing maintenance nightmare. OTOH it took me 2-3 hours to figure out and write the custom code from scratch, and I spent many more hours than that (and got more frustrated) trying to research and utilize the VB object library.

Added -----

After more review, I see that you added lines relating to $backupdb. That may have done the trick, but dealing with vB and its programming philosophy is just a nightmare, and I am too close to done to go backwards again. Thanks for your effort though.

andha513 08-05-2009 08:05 PM

I am porting all my users from a social networking site (Drupal CMS) to our new vBulletin forum, but having a small issue.

Since all Drupal passwords are already MD5'ed, I am simply creating vBulletin users manually by connecting to the vBulletin database and inserting the appropriate data into the user-table, the userfield-table and the usertextfield-table. (Since this is what I gather from the vBulletin registration script)
The users are created fine and working well, except that all users created with my script get the "Guest" title in their forum posts. And I just can't figure out why.
There are no users in the unregistered/guest usergroup (where people are assigned the "Guest" title), so that's not it.
We have no "Guest" user title in the User Title Manager, so that's not it either.

I'm assuming I'm missing to add some data to some table for each user. Would someone here be able to offer some help?

Thanks in advance.

ringleader 09-07-2009 01:22 PM

Quote:

Originally Posted by andha513 (Post 1862164)
We have no "Guest" user title in the User Title Manager, so that's not it either.

I'm assuming I'm missing to add some data to some table for each user. Would someone here be able to offer some help?

I assume you fixed your problem by now.

If not, you have to set the usergroup id for each member:
$newuser->set('usergroupid', 2);

andha513 09-07-2009 01:45 PM

Quote:

Originally Posted by ringleader (Post 1881122)
I assume you fixed your problem by now.

If not, you have to set the usergroup id for each member:
$newuser->set('usergroupid', 2);

Thanks, but I do set the usergroup id for each member (to 2).
Problem not really solved, but vBulletin's own "fix broken user profiles" feature does correct the user profiles, and I'm ok with this for now.

ringleader 09-07-2009 02:01 PM

usergroupid=2 is normally the default setting for the 'registered users' group.

Go to http://www.YourForumAddressHere.com/....php?do=modify and use whichever number for the usergroupid that you want to set for each member you're importing.

The usergroupid sets the permissions that you want the user to have on the forums.
Is that clearer for you?

andha513 09-07-2009 02:39 PM

I appreciate the effort, but I am aware of all this. Unless there is another database table related to the usergroups, the usergroups do not seem to be the problem here.


Quote:

Originally Posted by ringleader (Post 1881143)
usergroupid=2 is normally the default setting for the 'registered users' group.

Go to http://www.YourForumAddressHere.com/....php?do=modify and use whichever number for the usergroupid that you want to set for each member you're importing.

The usergroupid sets the permissions that you want the user to have on the forums.
Is that clearer for you?



All times are GMT. The time now is 06:55 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01918 seconds
  • Memory Usage 1,765KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete