That worked perfectly and it even persists the error messages, which means I can remove the "drupal_set_message" line I had included.<br><br>Thank you Saint-Genest, for the help and not shrugging me off and telling me to go to the support list like David did (which I did and did not receive a response).
<br><br><div><span class="gmail_quote">On 10/31/07, <b class="gmail_sendername">Saint-Genest Gwenael</b> <<a href="mailto:gwenael.saint-genest@makina-corpus.com">gwenael.saint-genest@makina-corpus.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br> Your "drupal_goto()" doesn't work because at this point the value
<br>of $_REQUEST['destination'] is already set [1]. So your drupal_goto()<br>will reload the page but not with 'user'. After reload no validation<br>is needed, your function is not called :(<br><br><br>I think, a quick solution is to unset 'destination' value before
<br>calling drupal_goto() :<br><br> function myutility_user_login_validate($form_id, $form_values) {<br> user_login_validate($form_id, $form_values);<br> if (count(form_get_errors()) > 0) {<br> unset($_REQUEST['destination']);
<br> drupal_set_message('test error message');<br> drupal_goto('user');<br> }<br><br>It's not a beauty solution but i think it's the simplest :)<br><br>Gwen<br><br><br>[1] <a href="http://api.drupal.org/api/function/drupal_goto/5">
http://api.drupal.org/api/function/drupal_goto/5</a><br><br><br>John Barreiros wrote:<br>> Hi<br>><br>> First, I realize what I'm doing isn't the most usable, but it's how the<br>> client wants it.
<br>><br>> On the homepage, the user login block is styled all fancy and compact.<br>> Unfortunately, it's compactness prevents a place for an error message if the<br>> user messes up their username or password.
<br>><br>> So, what I'd like to do, when the form fails validation, is redirect the<br>> user to "/user" which displays the regular login form along with the error<br>> messages that would of displayed within the block.
<br>> I tried the following (in my own module),<br>><br>> function myutility_form_alter($form_id, &$form) {<br>> switch ($form_id) {<br>> case 'user_login_block':<br>> $form['#validate'] = array('utility_user_login_validate' =>
<br>> array($form_id, $form));<br>> unset($form['links']);<br>> break;<br>> }<br>> }<br>><br>> function myutility_user_login_validate($form_id, $form_values) {<br>> user_login_validate($form_id, $form_values);
<br>> if (count(form_get_errors()) > 0) {<br>> drupal_set_message('test error message');<br>> //print "here";<br>> drupal_goto('user');<br>> }<br>> }<br>><br>
> The drupal_goto doesn't seem to work here. I'm fairly confident the code is<br>> making it to the drupal_goto because if I uncomment the "print" statement is<br>> does get called and prints out "here".
<br>><br>> Any ideas why drupal_goto isn't working in this case?<br>><br>> Thanks for the help.<br>><br><br></blockquote></div><br>