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
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

pedrofaria - July 15, 2008 - 11:34
Status:active» closed

I need override it to change form error message.

#2

ultimike - September 12, 2009 - 09:48
Status:closed» active

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

ultimike - September 12, 2009 - 09:53
Version:6.x-1.0» 6.x-2.0

Changing version to 6.x-2.0.

-mike

#4

pedrofaria - September 14, 2009 - 12:06
Status:active» fixed

OMG...

Thanks so much, mike...

Change has been committed.

Pedro Faria

#5

System Message - September 28, 2009 - 12:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.