Hey All,
I have searched and searched and seem and still cant find a solution to my custom registration form.
Here is something from my module code...
<?php
function test_form_user_register_alter(&$form, $form_state) {
if (isset($form_state['storage']['page_two'])) {
return test_form_page_two();
}
//page 1 of registration is displayed
$form['personal_info'] = array(
'#type' => 'fieldset',
'#title' => t('Personal Information'),
'#collapsible'=>TRUE,
);
$form['personal_info']['first-name'] = array(
'#title' => t('Your First Name'),
'#type' => 'textfield',
'#description' => t('Please enter your first name.'),
'#weight' =>'0',
);
$form['#validate'][] = 'test_form_validate';
$form['#submit'][] = 'test_form_submit';
return $form;
}
// Second page of registration
function test_form_page_two() {
$form['last-name'] = array(
'#type' => 'textfield',
'#title' => 'Last Name',
);
$form['finish'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
function test_form_validate($form, &$form_state){
// Validating page 2
if (isset($form_state['storage']['page_two'])) {
$last = $form_state['values']['last-name'];
if (!$last) {
form_set_error('last-name', 'Please enter a last name.');
}
return;
}
if ( strlen($form_state['values']['first-name']) < 2)
form_set_error('first-name', t('First name too short.'));
}
function test_form_submit($form, &$form_state) {
// Handle page 1 submissions
// process the form input...
// for the user-register, the submit form button id is edit-submit
if ($form_state['clicked_button']['#id'] == 'edit-submit') {
$form_state['rebuild'] = TRUE;
$form_state['storage']['page_two'] = TRUE;
}
else {
// finally
drupal_set_message('Your form has been submitted');
unset ($form_state['storage']);
}
}
I dont know what I am doing wrong, but the form just doesnt go to page 2. Any help is greatly appreciated! Thanks :))
Comments
Did you set the menus
Did you set the menus correctly?
Heshan Wanigasooriya
Github
menus?
we don't need no stinkin' menus.. lol
sorry, couldn't resist. menu's have nothing to do with this issue
Peter Lindstrom
LiquidCMS - Content Solution Experts
a few things
there are a few issues i can see here; but rather than detail them all - here is code for a module which you could use as an example of modifying user registration flow.
(i wanted to simply attach a zip but not allowed to attach files here.)
this module actually does a few things which are specific to my client's case.. but hopefully the user registration tweaks and comments in the code might server as clues for others.
this is what the module does:
- it uses Content Profile to add additional info for user during registration
actually a few complex bits here, but again... take it or leave it :)
- based on email domain the user enters we select the Organization (a node type with email domains entered)
- if the domain maps to a distinct Org we go to page 2 where the user is offered a set of roles to pick from (the one that best matches their role in the org)
- if the email domain does not match a distinct Org then we go to page 3 where the user selects from a reduced set of the Orgs (i.e. those that use the domain he entered)
- once he selects his Org then we proceed to Page 2 where he picks Role (as above)
The Roles that may be picked are in 2 groups - some which require no admin approval and if the user picks those we get the std send email with their password process flow. If they pick one of the "needs approval" roles then they are sent the email stating their request is pending approval.
as i said, a bit more complex than a simple multi-page user reg form.. but that's here as well.. hope it is of use
Peter Lindstrom
LiquidCMS - Content Solution Experts
drupal 5.x
it is function here will work with drupal 5.x ?
any answer is greatly appreciated.
Thanks
Great Module
Great module! it has exactly the features I need but unfortunately I'm having quite a hard time trying to get the module to override the default registration page. Please advise. Any help will be greatly appreciated.