Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-18-2007, 02:01 PM
Jim Nayzium Jim Nayzium is offline
 
Join Date: Mar 2007
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Registration fields INSERT into another dbase also?

I would like for my custom fields that I have added through the admin cp to INSERT into my custom database upon registration.

I have successfully hacked into the register.php and the functions_login.php to get it all to work on the 'pre-defined' fields...but the custom fields seems to have an array code that is over my head.

Basically, I have only added firstname and lastname fields, and I have another table in my database that is customized to use for my classifieds section, which is running a different custom software.

I am able to INSERT the username and password just fine tapping into the vBullein->userinfo stuff...and the GPC array.

However, my problem is it seems like the custom stuff is all inserted into one array and then that full array is inserted into the vb_ table all at once...

I know how to summon on row of an array using array['desiredinfo'] syntax...

but what if the desiredinfo is an array ??

seems like I want something like

array['desiredinfoArray']['desired_info_inside_this_array']

OR alternatively -- can someone just give me the best way to have the registration custom added fields be INSERTed into the vb database, AND into another database upon registration....

thanks.
Reply With Quote
  #2  
Old 03-20-2007, 01:07 AM
Flexserve Flexserve is offline
 
Join Date: Mar 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I need to know this also. No one on forums seems to know how, it's been asked several times.
Reply With Quote
  #3  
Old 03-20-2007, 01:29 AM
Jim Nayzium Jim Nayzium is offline
 
Join Date: Mar 2007
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I just finally solved this on my own.

I am so used to the phpBB open source world where every user is so helpful and everyone works so well together....

the catch is they NEED to be, cuz the software requires all that help...hahaha.

I love this vBulletin deal --- MUCHO....

$vbulletin->GPC['userfield']["field5"]
$vbulletin->GPC['userfield']["field6"]

are the values you need to insert for your custom fields...assuming these are the first two cusstom fields you added....

for me it was 5 -= first name and 6 =- last name

and I inserted them into another database table upon regisration....so they hit userfield5 and 6 in the vb_userfield tables....or usertext not sure which....

and they also hit my database table


PHP Code:
$insertSQL sprintf("INSERT INTO table_name (firstname, lastname) VALUES (%s, %s)",
GetSQLValueString($vbulletin->GPC['userfield']["field5"], "text"),
GetSQLValueString($vbulletin->GPC['userfield']["field6"], "text")); 
Of course GetSQLValueString is a dreamweaver code inserted when you insert your recordset to begin with...
Reply With Quote
  #4  
Old 03-20-2007, 04:53 PM
Flexserve Flexserve is offline
 
Join Date: Mar 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you explain where to put this??

Sorry, new to vbulletin ways of doing things and this is something I need to do asap.

Thanks in advance
Reply With Quote
  #5  
Old 03-20-2007, 06:56 PM
Jim Nayzium Jim Nayzium is offline
 
Join Date: Mar 2007
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

register.php starting around line 307

PHP Code:
$class mysql_pconnect('IP_ADDRESS_DBASE_HERE''DBASE_USER>HERE''DBASE_Password_HERE') or trigger_error(mysql_error(),E_USER_ERROR); 

//This is auto-created by DREAMWEAVER when you do a recordset.
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
//Here is the good part....
$insertSQL sprintf("INSERT INTO class_users (username, password, email, firstname, lastname) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($vbulletin->GPC['username'], "text"),
GetSQLValueString($vbulletin->GPC['password_md5'], "text"),
GetSQLValueString($vbulletin->GPC['email'], "text"),
GetSQLValueString($vbulletin->GPC['userfield']["field5"], "text"),
GetSQLValueString($vbulletin->GPC['userfield']["field6"], "text"));
mysql_select_db('DBASE-NAME-HERE-AGAIN'$class);
$Result1 mysql_query($insertSQL$class) or die(mysql_error()); 
My $class file is obviously my connection to my database....
Hope you understand the sprintf php command - if not do a google for sprintf and php....
Reply With Quote
  #6  
Old 03-20-2007, 07:13 PM
MarkPW MarkPW is offline
 
Join Date: Apr 2006
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is no need to modify vbulletin's files to achieve this. vB have a hook system of which allows you to execute external code at many different locations within vB's files, such as the registration or activation process.

See: What is a hook?

With regard to adding custom fields to a seperate db table upon registration - all you need to do is add a plug-in at the correct hook location (via the AdminCP), and include the code you wish to run. In this instance, you would add a hook at the following location: "register_addmember_complete" and include the database code you wish to run.

Similarly, if you only want to copy user details upon activation, you would use the hook, "register_activate_process".

Hope this helps!
Reply With Quote
  #7  
Old 03-20-2007, 07:19 PM
Jim Nayzium Jim Nayzium is offline
 
Join Date: Mar 2007
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

DUDE --- WHERE HAVE YOU BEEN!!!! This is great information....I am so used to OSCommerce and phpBB -- just hacking away at the actual code ---

MarkPW's way sounds much much better!!!
Reply With Quote
  #8  
Old 03-20-2007, 07:36 PM
MarkPW MarkPW is offline
 
Join Date: Apr 2006
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem
Reply With Quote
  #9  
Old 03-20-2007, 07:47 PM
Jim Nayzium Jim Nayzium is offline
 
Join Date: Mar 2007
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

One more quick one -- this has revolutionized my thinking, but I cannot quite wrap my head around it....

So I go to Add New Plugin---

and insert my custom php code in that box on that screen, and toggle the drop down to the location I want....and that is it??

Do I need to add a product or anything like that?

I am thinking I am going to remove all my customizations from the register.php and the functions_login.php files and put them in hooks so I can upgrade easier...

But I am not quite comprehending the whole process. I think it is so simple, I am just having a hard time believing it.

I attached a pdf screen grab of the page I am talking about.

No chance you could just walk me through a very simple one from start to finish...

something like, add this 123TEXT to this HOOK location and then watch the page refresh and see your text....

REALLY appreciate....
Attached Images
File Type: jpg snapshot.jpg (39.8 KB, 0 views)
Reply With Quote
  #10  
Old 03-20-2007, 08:37 PM
Flexserve Flexserve is offline
 
Join Date: Mar 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please do tell..we (a group) are trying to accomplish this very task.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:05 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.04207 seconds
  • Memory Usage 2,294KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete