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)

mikesharp 09-14-2009 11:15 AM

Is there an update on a working version of this for 3.8.x ???

thanks all

Mike

ragtek 09-14-2009 01:16 PM

Quote:

Originally Posted by mikesharp (Post 1884512)
Is there an update on a working version of this for 3.8.x ???

thanks all

Mike

No, the code is still working

webtechuser 09-24-2009 01:30 PM

I cant login from the site page using the user wich i have created according the way described above...can somebody plz help me :(

damianzaremba4 09-27-2009 01:56 PM

I get the error
Code:

Fatal error: Call to a member function query_read_slave() on a non-object in /var/www/test_forums/includes/functions_misc.php on line 789
Every time I try to run the code:
PHP Code:

function register($username$password$email){
        
define('VB_AREA''External');
        
define('SKIP_SESSIONCREATE'0);
        
define('SKIP_USERINFO'1);
        
define('CWD'$this->forum_path);
        require_once(
CWD '/includes/init.php');

        
$newuser =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
        
$newuser->set('username'$username);
        
$newuser->set('email'$email);
        
$newuser->set('password'$password);
        
$newuser->set('usergroupid'$this->forum_awaiting_confomation_group);

        if(empty(
$newuser->errors)){
            return 
$newuser->save();
        }else{
            return 
$newuser->errors;
        }


Any one got an idea why?

Thanks.

Andreas 09-30-2009 04:25 PM

Quote:

Any one got an idea why?
Yep - Variable Scope.

Booting vBulletin from non-global scope is a bit tricky.

Crimm 11-11-2009 06:37 PM

Quote:

Originally Posted by php-resource.de (Post 1809919)
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




I just wanted to say that I was implementing this article with Wordpress and kept getting errors about functions_databuild.php on line 1685. So I added "global $vbulletin" and started having the issue of class_dm.php on line 177 about Registry Object. The above code worked for me.

So here's my function (A combination of those in this article for wordpress)

Code:

// Function for vB registration //

function register_in_vb($username, $password, $email){
        define('VB_AREA', 'External');
        define('SKIP_SESSIONCREATE', 0);
        define('SKIP_USERINFO', 1);
        define('CWD', 'ABSOLUTE_VB_PATH' );
        require_once(CWD . '/includes/init.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', 3);

        if(empty($newuser->errors)){
                        $db = $backupdb;
            return $newuser->save();
        }else{
                    $db = $backupdb;
            return $newuser->errors;
        }
               
}

and I called it on wp-login.php in the register_new_user function. I added it right after the User Password Generation so I could pass it to vB.

Code:

        // Add the users to vBulletin
        $newuserid = register_in_vb($user_login, $user_pass, $user_email);

That should help some people if you come across this :P

yappa.be 11-27-2009 06:51 AM

Hello,


A few weeks ago, we launched a website with a custom registration in stead of register.php to add new users. With the help of this forum, we succeeded without any problems.

Since last monday, the register was down. The php-code did not change so we have no clue what so ever what could be the problem.

Error code:
HTML Code:

<b>Fatal error</b>:  Call to a member function query_read() on a non-object in <b>/var/www/html/forum/includes/adminfunctions.php</b> on line <b>2403</b><br />
PHP Code:

//load the vbulletin framework
            
define('VB_AREA''External');
            
define('SKIP_SESSIONCREATE'1);
            
define('SKIP_USERINFO'1);
            
define('CWD'PATH);

            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;        
            
            
$newuser =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
            
$newuser->set('username'$this->data['User']['firstname'].' '.$this->data['User']['lastname']);
            
$newuser->set('email'$this->data['User']['email']);
            
$newuser->set('password'$this->data['User']['password']);
            
$newuser->set('birthday'$this->data['User']['birthday']);
            
            
$newuser->set('usergroupid'2);  
            
            
$userfields['field11'] = $this->data['User']['optin'];
            
$userfields['field5'] = $this->data['User']['abo_nr'];
            
$userfields['field6'] = $this->data['User']['firstname'];
            
$userfields['field7'] = $this->data['User']['lastname'];
            
            
            
//userfields
            
$newuser->set_userfields($userfields);
            if(
$this->data['User']['password']!=$this->data['User']['retype_password']){
                
$newuser->errors[] = 'password_error';
            }
            
            
            if(!
$newuser->errors){
                if(
$newuserid $newuser->save()){
                                      echo 
'success';exit;
                                }
                        } 

After doing some searching, we found that the error is generated in the function build_options in includes/adminfunctions.php. This function is called in includes/class_core.php in the function check_options.

Does anybody have an idea what could be the problem. It seems that because of some changes in the settings (or something like that), we lost our database-object but didn't change anything to the code itself.

Crimm 11-27-2009 07:56 PM

I just happen to pass by here looking for something else and I saw your response.

Did you add a profile field, maybe?

Just a thought. If you get it figured out, please post the solution :)

bianca_roma 12-01-2009 10:09 AM

Quote:

Originally Posted by andha513 (Post 1862164)
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.

I have the same problem...Did you manage to resolve this issue? i'm desperate...

Iron Star 01-06-2010 03:27 PM

Unfortunately, I obtain this:

Fatal error: Call to a member function do_db_fetch() on a non-object in vb_forum/includes/init.php on line 308

An idea?


Quote:

Originally Posted by Crimm (Post 1912798)
I just wanted to say that I was implementing this article with Wordpress and kept getting errors about functions_databuild.php on line 1685. So I added "global $vbulletin" and started having the issue of class_dm.php on line 177 about Registry Object. The above code worked for me.

So here's my function (A combination of those in this article for wordpress)

Code:

// Function for vB registration //

function register_in_vb($username, $password, $email){
        define('VB_AREA', 'External');
        define('SKIP_SESSIONCREATE', 0);
        define('SKIP_USERINFO', 1);
        define('CWD', 'ABSOLUTE_VB_PATH' );
        require_once(CWD . '/includes/init.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', 3);

        if(empty($newuser->errors)){
                        $db = $backupdb;
            return $newuser->save();
        }else{
                    $db = $backupdb;
            return $newuser->errors;
        }
               
}

and I called it on wp-login.php in the register_new_user function. I added it right after the User Password Generation so I could pass it to vB.

Code:

        // Add the users to vBulletin
        $newuserid = register_in_vb($user_login, $user_pass, $user_email);

That should help some people if you come across this :P



All times are GMT. The time now is 12:20 AM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03395 seconds
  • Memory Usage 1,810KB
  • 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_html_printable
  • (3)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