Posted by maria_zk on June 12, 2010 at 3:17am
I am trying to display a page after a user has filled in the registration form, where a confirmation message would appear. Are you sure you want to register? Yes / No. User should be created only if the answer is Yes.
I have some code here, that fails to override the core user register submit function.
<?php
function confirm_registration_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'user_register':
$key = array_search('user_register_submit', $form['#submit']);
if ($key !== FALSE) {
unset($form['#submit'][$key]);
}
array_unshift($form['#submit'],'confirm_registration_user_register_submit');
break;
}
}
function confirm_registration_user_register_submit(&$form, $form_state) {
if (isset($form_state['values']['mail'])) {
return _confirm_registration_confirm($form_state);
}
return user_register_form($form_state);
}
function _confirm_registration_confirm(&$form_state) {
$desc = 'Are you sure you want to register?';
// Tell the submit handler to process the form
$form['process'] = array('#type' => 'hidden', '#value' => 'true');
// Make sure the form redirects in the end
$form['destination'] = array('#type' => 'hidden', '#value' => 'example/todo');
return confirm_form($form,
'Are you sure?',
'example/add',
$desc,
'Continue',
'Start again');
}
?>Any ideas would be really welcomed :)
Moved by VM
Comments
Can't help you with that, but
Can't help you with that, but try the Module development forum instead of this forum.
Blog
rules
The Rules module has some "events" that can trigger actions that occur before any processing occurs. I've never tried it though. That could redirect the user to your yes/no page, but I don't know how you could complete the process if the user clicks yes. Perhaps Rules can handle that, too.
Thank you for your replies,
Thank you for your replies, Rules would be helpfull if there was an Event like "user is about to be created" or something. What i need is to redirect the submit to another form but without the user being really created. I see my post has been tranfered to the module dev section :)
Any update on this?
Any update on this? I'm looking to do the same exact thing.
This looks like the same answer
I posted this today:
http://drupal.org/node/385640#comment-3912092
It ties the answer together for the code you are using before and FAPI's $form_state['rebuild'] state. I link to another node there that is based on the code you have above. I would answer further but your naming convention is confusing. Is your module's name "confirm_registration". Correct me if I misspeak but, I believe that that the use of hook_form_alter has a child function called hook_form_id_form_alter. You would still need the module name in the front of your alter function.