Home · Links · Contact Us
Home arrow Forums
Home
Features
FAQ
Screen Shots
Modules
Themes
Demos
Documentation
Forums
Contact Us
Download
Purchase
Quotes

" ... I want to tell you that your thyme product is functional and valuable beyond words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."

" ... Thanks for such a complete project, its making my job much easier. ..."

" ... I have now deployed 4 different calendars and our users love them ... "

" ... Easy to install and use and a great look/design. ..."

" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."


  FAQFAQ    SearchSearch  RegisterRegister   Log inLog in 
Adding more fields to the 'register_user" module
Goto page 1, 2  Next
 
Post new topic   Reply to topic     Forum Index -> Hacking Thyme
View previous topic :: View next topic  
Author Message
Cave_Dweller



Joined: 27 Oct 2008
Posts: 40

PostPosted: Sun Dec 14, 2008 7:57 pm    Post subject: Adding more fields to the 'register_user" module Reply with quote

I need to collect more information from users who register so I need to add more input fields to the register_user module. Fields: company; city, state, zip; phone; web address, general info about events posted.

This would also mean redoing the template so the the input fields are arranged in a columns vertical format as I want to keep the width to its current dimension.

Adding the fields to the DB using phpMyAdmin is already done and I've tried to modify the fields with no luck.
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Mon Dec 15, 2008 4:57 pm    Post subject: Reply with quote

Hi,

RE: Adding the fields to the DB using phpMyAdmin is already done and I've tried to modify the fields with no luck.

Did you add them to a specific table in the database or did you create a new one? How have you tried to modify the fields exactly?
Back to top
View user's profile Send private message Visit poster's website
Cave_Dweller



Joined: 27 Oct 2008
Posts: 40

PostPosted: Mon Dec 15, 2008 5:31 pm    Post subject: Reply with quote

I used phpMyAdmin to add about half dozen new fields to the 'user' table. I did not modify any of the existing fields, just added new ones. The calendar and registration module still function as designed, no problem.

Now I need to change the registration input form, template and subsequent query so it inserts those extra form inputs into the table fields. I added about 6 extra form fields, so the template needs to be changed to a vertical, two column format with the label on the left and input box on the right. The horizontal format will be too wide to fit into my page border.

I tried making changes on a copy of the files in question, but couldn't make anything work. (BTW- I'm a senior citizen who self taught php when I was 65--I get by, but the elegance of your code is beyond me)

(FYI-- I am building a couple of external admin pages that query that table and another new one I just created and list the information from them, They will have no connection or not modify the calendar code in any way.)
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Mon Dec 15, 2008 7:23 pm    Post subject: Reply with quote

Hi,

To get the table to be vertical, edit modules/user_registration/reg.php around line 131 and change this part:

Code:

      $_cal_table = new _cal_table();
      $cols = array (
         _USERNAME_,
         _NAME_,
         _EMAIL_,
         _PASSWORD_,
         ""
      );
      $_cal_table->print_header($cols);

      $_cal_table->print_row(array (
         $form->textbox('new_user', 20, " maxlength=32"),
         $form->textbox('new_name', 20, " maxlength=128"),
         $form->textbox('new_email', 20, " maxlength=128"),
            $form->textbox('new_pass', 8),

            "<input type='button' class='button' value='" . _USERREG_REGISTER_ . "' onClick='load()'>"));

         
      $_cal_table->print_footer();


To something line this:

Code:

      $_cal_table = new _cal_table();
      $_cal_table->vertical = true;
      $_cal_table->print_header(array());
      $_cal_table->col_count = 2;

      $_cal_table->print_row(array (_USERNAME_,
         $form->textbox('new_user', 20, " maxlength=32")));

      $_cal_table->print_row(array (_NAME_,$form->textbox('new_name', 20, " maxlength=128")));

      $_cal_table->print_row(array (_EMAIL_,$form->textbox('new_email', 20, " maxlength=128")));

      $_cal_table->print_row(array (_PASSWORD_,$form->textbox('new_pass', 8)));

      $_cal_table->print_row(array("<input type='button' class='button' value='" . _USERREG_REGISTER_ . "' onClick='load()'>"), true);

      $_cal_table->print_footer();


You can see how to create a row in the table from the above example. I'm still trying to find where it inserts the information. This module was written and donated by a Thyme user.
Back to top
View user's profile Send private message Visit poster's website
Cave_Dweller



Joined: 27 Oct 2008
Posts: 40

PostPosted: Mon Dec 15, 2008 8:29 pm    Post subject: Reply with quote

Great, that works perfect so far!
Thanks,
John
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Tue Dec 16, 2008 6:37 pm    Post subject: Reply with quote

This is no small task.

It looks like next you'd have to change this part of the JavaScript:

Code:
    var user = elms['new_user'].value;
    var name = elms['new_name'].value;
    var email = elms['new_email'].value;
    var pw = elms['new_pass'].value;
    var getParms = 'new_user=' + user + '&new_name=' + name + '&new_email=' + email + '&new_pass=' + pw;


In that same file to include your newly added fields.

In that same file, add your fields to this part:

Code:
      $nuser = new _cal_user($_cal_userreg_record->userid, $_cal_userreg_record->password);
      $nuser->userid = $_cal_userreg_record->userid;
      $nuser->fields[] = 'pass'; // why? This is done in user module, but why?
      $nuser->pass = $_cal_userreg_record->password;
      $nuser->access_lvl = 0;
      $nuser->name = $_cal_userreg_record->name;
      $nuser->email = $_cal_userreg_record->email;
      $nuser->save();

Then edit modules/user_registration/class.userreg_record.php and add your fields to this line:

Code:
$this->_init($reqorses['new_user'], $reqorses['new_pass'], $reqorses['new_name'], $reqorses['new_email']);


The function _init definition and body.

The function values body..

This line in function load():

Code:
list($userid, $password, $email, $name) = explode('|', $ses['session_data'], 4);


This part of function register():

Code:
     $v = implode("|", array (
         $this->userid,
         md5($this->password
      ), $this->email, $this->name));


That should do it. Let me know how it goes.
Back to top
View user's profile Send private message Visit poster's website
Cave_Dweller



Joined: 27 Oct 2008
Posts: 40

PostPosted: Tue Dec 16, 2008 11:57 pm    Post subject: Reply with quote

I've been through it umpteen times verifying the changes, but when I click the submit button nothing happens.
The table labels are odd, too.
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Dec 17, 2008 12:02 am    Post subject: Reply with quote

Hi,

Do both of the files involved pass PHP validation?
Back to top
View user's profile Send private message Visit poster's website
Cave_Dweller



Joined: 27 Oct 2008
Posts: 40

PostPosted: Wed Dec 17, 2008 12:10 am    Post subject: Reply with quote

I retyped it with fresh files this morning and found that now the system actually functions in terms of action when the button is pushed and the verification email is sent, but the data from the extra fields was not inserted into the database.

I believe the error that I had up until now was found in the class.userreg_record.php:

list($userid, $password, $email, $name) = explode('|', $ses['session_data'], 4);

Now the new line is

list($userid, $password, $email, $name, $company, $city, $state, $phone, $website, $comments) = explode('|', $ses['session_data'], 10);

I had not changed the number at the end to 10 from 4, which represents the number of variables being insterted into the session,

--AND-- this line
$this->_init($userid, $password, $name, $email);
Needs to be this:
$this->_init($userid, $password, $name, $email, $company, $city, $state, $phone, $website, $comments);

Close, but no cigar.
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Dec 17, 2008 4:53 pm    Post subject: Reply with quote

Hi,

So it's getting lost somewhere. When a user registers, before they actually click on the link in the e-mail to activate their account, do you see a record in the thyme_Sessions table with their information in it? A query like this should find it:

select * from thyme_Sessions where session_data like '%userid%';

Where userid is the userid they registered for. Does this line contain the additional information?
Back to top
View user's profile Send private message Visit poster's website
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Dec 17, 2008 4:58 pm    Post subject: Reply with quote

Ahh... also, I forgot that the user class has its fields assigned in the script rather than reading them from the table. In modules/user_registration/reg.php, you should see a line that looks like this around line 97:

Code:
$nuser->fields[] = 'pass';


.. below that, add your extra fields like this:\

Code:
$nuser->fields[] = 'phone';
$nuser->fields[] = 'website';
.. and so on ..


Make sure that these exactly match the table field names you've added to the thyme_Users table.
Back to top
View user's profile Send private message Visit poster's website
Cave_Dweller



Joined: 27 Oct 2008
Posts: 40

PostPosted: Wed Dec 17, 2008 6:08 pm    Post subject: Reply with quote

I really appreciate all the time you're spending on this.
Changed that section to

$nuser = new _cal_user($_cal_userreg_record->userid, $_cal_userreg_record->password);
$nuser->userid = $_cal_userreg_record->userid;
$nuser->fields[] = 'pass'; // why? This is done in user module, but why?
$nuser->pass = $_cal_userreg_record->password;
$nuser->access_lvl = 0; // JC Sets PERMISSIONS
$nuser->name = $_cal_userreg_record->name;
$nuser->email = $_cal_userreg_record->email;
$nuser->fields[] = 'company'; //JC adds
$nuser->fields[] = 'city'; //JC adds
$nuser->fields[] = 'state'; //JC adds
$nuser->fields[] = 'phone'; //JC adds
$nuser->fields[] = 'website'; //JC adds
$nuser->fields[] = 'comments'; //JC adds
$nuser->save();


I had it as this, following the convention of the lines right above it.

$nuser = new _cal_user($_cal_userreg_record->userid, $_cal_userreg_record->password);
$nuser->userid = $_cal_userreg_record->userid;
$nuser->fields[] = 'pass'; // why? This is done in user module, but why?
$nuser->pass = $_cal_userreg_record->password;
$nuser->access_lvl = 0; // JC Sets PERMISSIONS
$nuser->name = $_cal_userreg_record->name;
$nuser->company = $_cal_userreg_record->company; //JC adds
$nuser->city = $_cal_userreg_record->city; //JC adds
$nuser->state = $_cal_userreg_record->state; //JC adds
$nuser->phone = $_cal_userreg_record->phone; //JC adds
$nuser->website = $_cal_userreg_record->website; //JC adds
$nuser->comments = $_cal_userreg_record->comments; //JC adds
$nuser->save();

The process is working again, but the new extra fields are not being loaded in. The all show as null in the table.

Please take a look at the form
http://www.meetingsandmixers.com/events/calendar/index.php?module=user_registration

Note that there must be some reference table somewhere on another page that converts some of the form element names to upper and lower case and some don't convert. Again, I followed the convention of the existing lines and 'Phone' was changed to upper and lower case while the other new ones weren't.

$_cal_table = new _cal_table();
$_cal_table->vertical = true;
$_cal_table->print_header(array());
$_cal_table->col_count = 2;

$_cal_table->print_row(array (_USERNAME_,
$form->textbox('new_user', 20, " maxlength=32")));

$_cal_table->print_row(array (_NAME_,$form->textbox('new_name', 20, " maxlength=128")));

$_cal_table->print_row(array (_EMAIL_,$form->textbox('new_email', 20, " maxlength=128")));

$_cal_table->print_row(array (_PASSWORD_,$form->textbox('new_pass', Cool));

$_cal_table->print_row(array (_COMPANY_,$form->textbox('new_company', 20, " maxlength=128")));

$_cal_table->print_row(array (_CITY_,$form->textbox('new_city', 20, " maxlength=128")));

$_cal_table->print_row(array (_STATE_,$form->textbox('new_state', 20, " maxlength=128")));

$_cal_table->print_row(array (_PHONE_,$form->textbox('new_phone', 20, " maxlength=14")));

$_cal_table->print_row(array (_WEBSITE_,$form->textbox('new_website', 20, " maxlength=128")));

$_cal_table->print_row(array (_COMMENTS_,$form->textbox('new_comments', 20, " maxlength=256")));

$_cal_table->print_row(array("<input type='button' class='button' value='" . _USERREG_REGISTER_ . "' onClick='load()'>"), true);

$_cal_table->print_footer();
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Dec 17, 2008 6:20 pm    Post subject: Reply with quote

Instead of using _PHONE_, you can just use "Phone" ..etc.. Change _COMPANY_ to "Company" like so:

Code:
$_cal_table->print_row(array ("Company",$form->textbox('new_company', 20, " maxlength=128")));


The other method depends on Thyme having a translation defined for _COMPANY_.

That entire section should be:

Code:

$nuser = new _cal_user($_cal_userreg_record->userid, $_cal_userreg_record->password);
$nuser->userid = $_cal_userreg_record->userid;

# Inform user class of added fields
$nuser->fields[] = 'pass'; // why? This is done in user module, but why?
$nuser->fields[] = 'company'; //JC adds
$nuser->fields[] = 'city'; //JC adds
$nuser->fields[] = 'state'; //JC adds
$nuser->fields[] = 'phone'; //JC adds
$nuser->fields[] = 'website'; //JC adds
$nuser->fields[] = 'comments'; //JC adds

# Assign values to fields
$nuser->pass = $_cal_userreg_record->password;
$nuser->access_lvl = 0; // JC Sets PERMISSIONS
$nuser->name = $_cal_userreg_record->name;
$nuser->email = $_cal_userreg_record->email;
$nuser->company = $_cal_userreg_record->company; //JC adds
$nuser->city = $_cal_userreg_record->city; //JC adds
$nuser->state = $_cal_userreg_record->state; //JC adds
$nuser->phone = $_cal_userreg_record->phone; //JC adds
$nuser->website = $_cal_userreg_record->website; //JC adds
$nuser->comments = $_cal_userreg_record->comments; //JC adds

$nuser->save();


Let me know if that doesn't do it.
Back to top
View user's profile Send private message Visit poster's website
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Dec 17, 2008 6:22 pm    Post subject: Reply with quote

Actually, if that doesn't work, change this line:

Code:
$nuser->comments = $_cal_userreg_record->comments; //JC adds


.. .to this ..

Code:
$nuser->comments = "Test field add";


.. and then try again.

That way we can see if data is not getting to that point, or data is getting to that point but is not inserted into the new user record.
Back to top
View user's profile Send private message Visit poster's website
Cave_Dweller



Joined: 27 Oct 2008
Posts: 40

PostPosted: Wed Dec 17, 2008 6:35 pm    Post subject: Reply with quote

Didn't work, but changing the line to
$nuser->comments = "Test field add";

added Test field add to the comments field in the table. so the data is getting there, it's just not getting collected. All the other new cells were null

Where is this defined?
$_cal_userreg_record
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Hacking Thyme All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2005 eXtrovert software unless otherwise noted. All rights reserved.
Portions © 2004 Ben Brown. All rights reserved.
Trademarks are property of their respective owners.