The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
![]()
Hi
Can anyone give me some information regards the registration process and the structure of the register.php file? There are some parts of the code that I am unable to figure out quite what is going on as I don't have sufficient knowledge of the way vbulletin works (I find it very convoluted and hard to follow at times - though once I do figure something out just how someting works the code is always elegant) Anyway the modifications I am trying to make mean I need to understand the registration process better I have already figured out I need to look at a particular section of register.php which is this section: Code:
if ($_POST['do'] == 'addmember') Code:
// assign user to usergroup 3 if email needs verification if ($vbulletin->options['verifyemail']) { $newusergroupid = 3; } else if ($vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser']) { $newusergroupid = 4; } else { $newusergroupid = 2; } $userdata->set('usergroupid', $newusergroupid); The bit I am not sure about exactly is $userdata->set('usergroupid', $newusergroupid); the $userdata->set() is a method (function) which is part of an array of methods? Code:
// set languageid $userdata->set('languageid', $vbulletin->userinfo['languageid']); // set user title $userdata->set_usertitle('', false, $vbulletin->usergroupcache["$newusergroupid"], false, false); // set profile fields $customfields = $userdata->set_userfields($vbulletin->GPC['userfield'], true, 'register'); // register IP address $userdata->set('ipaddress', IPADDRESS); More use of this $userdata->set() - but is set() the actual function that is writing the fields to the userfields file in the database or are we just building an array here? I guess really I need to know where the code for $userdata->set() is before i could answer that myself, which is what I am asking here Also what exactly is GPC() it crops up a lot but I have never really understood it (or had the need to yet) Code:
($hook = vBulletinHook::fetch_hook('register_addmember_process')) ? eval($hook) : false; Can someone explain (or point me in the direction of understanding) what this line of code actually does - I know the eval($hook) executes the contents of the variable $hook as though it was php. But what code is this $hook variable containing here and how did it get there? And why not simply put the necessary executable php in register.php without all this hook malarky to confuse things? Code:
$userdata->pre_save(); Code:
// check for errors if (!empty($userdata->errors)) { $_REQUEST['do'] = 'register'; $errorlist = ''; foreach ($userdata->errors AS $index => $error) { $errorlist .= "<li>$error</li>"; } $username = htmlspecialchars_uni($vbulletin->GPC['username']); $email = htmlspecialchars_uni($vbulletin->GPC['email']); $emailconfirm = htmlspecialchars_uni($vbulletin->GPC['emailconfirm']); $parentemail = htmlspecialchars_uni($vbulletin->GPC['parentemail']); $selectdst = array($vbulletin->GPC['dst'] => 'selected="selected"'); $sbselected = array($vbulletin->GPC['showbirthday'] => 'selected="selected"'); $show['errors'] = true; } else { $show['errors'] = false; Code:
// save the data $vbulletin->userinfo['userid'] = $userid = $userdata->save(); Thanks for any help or guidance --------------------------------------------------------- OK this next bit describes what I am actually trying to do in case it assists anyone trying to help me. It isn't really necessary for anyone to read this part, if they just want to answer the questions above. But for a deeper understanding of my site.... On my site I have a custom user field called postcode Basically when a user registers they enter the first part of their postcode which technically is called an 'outcode' and this identifies the town or city the member lives in but not the actual address There is in my database a postcodes file which contains these five fields: outcode, city/county, town, x and y coordinates The x and y co-ords are in metres starting from the bottom left hand corner of the UK (Lands End) which is x=0.0000 y=0.0000 The way another programmer working on my site implemented the next bit is the problem. When listing members in memberlist (or in forum postbits) the site uses Ajax to look up each outcode in the postcode database, and display the city or county. On actual profiles it displays the city/county + town. If someone clicks on the city/county in memberlist or postbits, the site then looks up that city or county in the postcodes database, finds all the outcodes relating to that city or couty, and finally lists all members who live in that city regardless of their actual outcode Also I have a member search facility that uses the x and y co-ordinates to find all members living within x miles (as the crow flies) using a pythagorean formula So that's what I have implemented at the moment and it works OK. The problem is that as the memberlist gets bigger, the Ajax that looks up the city/county from the postcodes database everytime is slowing things down too much So I have now added another custom userfield called 'Location' The memebrs cant' access this field directly. I added some code to memberlist.php so I can run an 'admin' function that looks up each member, uses the outcode to find the city/county and then stores this in the Location field. This all works OK. So if for example I change the postcodes file (add or change an outcode) then I can run this function to update all my members locations I am now using this Location field to display in memberlists and postbits so I no longer need the Ajax which was slowing the site down a lot What I now need to do is add code to the registration which looks up the outcode $userinfo[field6] in the postcodes file and stores the returned city/county in $userinfo[field98] Basically I need to know in the register.php file exactly where I have access to $userinfo[field6] so I can add my code do this. And also will I have access to $userinfo[field98] which is not one of the fields the member can fill in during registration I also need to do a similar alteration when a user edits their profile (as they may change the outcode) but I haven't got as far as looking at that yet Rich |
#2
|
|||
|
|||
![]() Quote:
I believe set() sets a property in the object, and a later call to save() will actually write stuff to the database (and I believe presave() is called when all the set()'s are doen but before the actual database write). There might be info somewhere else on the site about using data managers but I don't know offhand where. In case you're not familiar with object oriented stuff it's probably worth reading over this section of the php manual: http://us2.php.net/manual/en/language.oop5.php Quote:
Quote:
|
#3
|
||||
|
||||
![]()
Hi
And thanks for that it does clear some stuff up for me. I am not brilliant with OOP (I think it just kinda clouds the issue rather than just getting on with it) but I do understand the principles of it. Now let's see What I am trying to do here is take a value the member inputs at registration (the outcode - which is the UK postcode minus the last three digits and specifies the area they live in) This value gets stored on my site in $userinfo[field6] during the normal registration process I need to add some code so I can look up this outcode in the database (in my custom postcodes file) and then write the returned value (the city or county) to $userfield[field98] - which the user can not edit directly. This ensures I guess, amongst other things, that the always get the same city/county for entering the same outcode. Are you saying I could add the code I need in a 'plugin' and then this would be evaluated as part of the register_addmember_process hook instead of editing the register.php itself? I never even thought of doing it that way (or even knew I could!) as like I say I am a beginner at php and even more so at VB so I just dive in at the deep end and start editing files. Or maybe that's the electronics engineer in me coming out - I understand the low level stuff far better than the layers built upon it! However I do see what you mean about the advantage of adding mods using the plugin system - in fact it's quite a relevation to me now you explained it ![]() A lot of stuff was already done by someone I payed to work on the site previously (and a lot of the mess I am trying to clear up now since they did a runner on me!) but as things stand it does restrict me from upgrading to VB4 at the moment due to the amount of modified php files I have Having said that I do believe I am doing a lot with VB it was never really intended to do - like my site is of a more social (often physically!) networking site than a forum - so if you don't mind the adult content please feel free to take a look at what I have done with it ![]() Rich --------------- Added [DATE]1290466144[/DATE] at [TIME]1290466144[/TIME] --------------- Oh and PS - now you explained all that hook malarky - like everything else I discover about VB - once it is explained to me, the resulting answer is always elegant ![]() |
#4
|
|||
|
|||
![]() Quote:
I haven't studied register.php that closely so I don't know off the top of my head where you should put your code. Maybe someone else who does will read this. But if you think you still need help figuring it out I could look at it. |
#5
|
||||
|
||||
![]()
OK thanks for that - I'll have a go (one factor I worry about is whether the $userfield[field98] will be actually written to the database - as it is not an 'user editable' field as I added it in the ACP - but then I guess the worse that could happen is the locations don't get saved
So I'll have a play and let you know how I get on. Thanks for the info Rich |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|