2

我在 drupal 6 中创建了一个重置​​密码表单。提交时我必须重定向到同一页面显示 Drupal 消息。

我写了以下内容:

  global $language;

  $account = $form_state['values']['account'];

  _user_mail_notify('password_reset', $account, $language);


  watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));

  drupal_set_message(t('Further instructions have been sent to your e-mail address.'));

  $form_state['redirect'] = 'user/password';
  return;

}

但我的邮件代码工作正常,但我的消息没有显示。

4

4 回答 4

2

试试这个代码,它会在同一页面上重定向你并显示消息......

$msg = "Further instructions have been sent to your e-mail address.";
drupal_set_message($msg, $type = 'status');
drupal_goto('user/password');
于 2015-05-07T10:12:21.870 回答
1
  • 您是否尝试过切换回 Garland(检查主题是否有问题)?
  • 您是否检查过您的用户表有一个 0(零)匿名条目?由于 uid 字段的自动增量设置,有时导入的表会丢失该行。
  • 消息是否显示给经过身份验证的/管理员用户?
  • 我假设您的代码段是提交处理程序?我假设$form_state是通过引用传递的?
于 2013-04-10T14:50:59.593 回答
1

您可以尝试使用此代码重定向到带有消息的另一个页面

drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
drupal_goto('user/password');
于 2015-04-14T08:43:07.187 回答
1

而不是$form_state['redirect']使用该drupal_goto功能:

drupal_set_message(
    'Further instructions have been sent to your e-mail address.',
     'status', $repeat = FALSE);
drupal_goto('user/password');
于 2015-05-21T05:56:03.463 回答