array position should not be hard coded
agerson - July 15, 2008 - 04:38
| Project: | No request new password |
| Version: | 6.x-2.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
On line 49 of norequestnewpass.module you should change
$form['#validate'][2] = 'noreqnewpass_user_login_final_validate';to
$form['#validate'][] = 'noreqnewpass_user_login_final_validate';This way if other modules want to override the same forms you will not conflict with them.

#1
I need override it to change form error message.
#2
Hmm - it looks like you already have the code there to pretty much fix this the correct way. I see that you just want to replace the "user_login_final_validate()" function with the "noreqnewpass_user_login_final_validate()" function. Here's the code as it exists now:
if (($form_id == 'user_login_block' || $form_id == 'user_login') && variable_get('noreqnewpass_disabled', true)) {$key = array_search('user_login_final_validate', $form['#validate']);
$form['#validate'][2] = 'noreqnewpass_user_login_final_validate';
}
It looks like you started the solution but didn't finish it. Just change the hardcoded "2" to "$key" and you're done!
if (($form_id == 'user_login_block' || $form_id == 'user_login') && variable_get('noreqnewpass_disabled', true)) {$key = array_search('user_login_final_validate', $form['#validate']);
$form['#validate'][$key] = 'noreqnewpass_user_login_final_validate';
}
Or am I missing something?
Thanks,
-mike
#3
Changing version to 6.x-2.0.
-mike
#4
OMG...
Thanks so much, mike...
Change has been committed.
Pedro Faria
#5
Automatically closed -- issue fixed for 2 weeks with no activity.