Registration Form
Archived from the Xataface Users forum.
rwzhao — Sun Feb 22, 2009 11:07 pm
Hello! Steve,
I have a couple of questions regarding the registration form.
- I have two tables - User and Profiles
Users: (id, username, password, email,profile_id)
Profiles:(profile_id, firm_name, address, phone, etc)
-
User_table will be Users.
-
How can customize registration form to have the fields from both tables? After the user registered and validated, how can update the both tables using the collected data from table-dataface__registration.
Thanks.
shannah — Mon Feb 23, 2009 7:34 pm
Currently the registration form only includes fields from the users table. What I generally do if I have additional information I want the user to give me upon registration is force them to a particular form after they have registered.
E.g. in the Application delegate class you can implement the beforeHandleRequest() method that checks to see if the user has created a profile yet, and if not, redirects them to the “New Profile” form with a message asking them to complete their profile to continue.
For example:
- Code: Select all
function beforeHandleRequest(&$record){ $app =& Dataface_Application::getInstance(); $query =& $app->getQuery(); $auth =& Dataface_AuthenticationTool::getInstance(); $user =& $auth->getLoggedInUser(); if ( $user and !$user->val('profile_id') ){ // profile hasn't been created yet if ( !($query['-table'] == 'Profiles' and $query['-action'] == 'new' )){ // We aren't on the new record form of profiles - so // let's redirect there header(DATAFACE_SITE_HREF.'?-action=new&-table=Profiles&--msg='.urlencode('Please fill in your profile to continue.')); exit; } } }
Note that with this scheme you probably want to do the following also:
-
Set permissions so that users can’t create more than one profile.
-
add an afterInsert() trigger to the Profile’s table to automatically add the profile_id to the current user’s record in the Users table.
-Steve
}
}
}
rwzhao — Wed Feb 25, 2009 12:15 am
Steve,
Thanks.
Follow your instruction, I get the warning message at the top of the page:
Warning: Missing argument 1 for conf_ApplicationDelegate::beforeHandleRequest(), …..
Still not direct to other page.
I have checked all the typing in the code and it seems no mistypes.
shannah — Wed Feb 25, 2009 9:18 am
Sorry… beforeHandleRequest actually doesn’t take any arguments. Remove the &$record parameter.