2013-02-27 22 views
0

我試圖在用戶註冊時打印消息。我創建了一個調用drupal_set_message並返回'/'的表單提交處理程序。我在我的提交處理程序中放置了一個看門狗消息,以確保它被調用,並且是。表單重定向丟失的Drupal消息

重新定向後,我雖然沒有收到消息。我從devel調試dpms不起作用,我的drupal_set_message不起作用,等等。正在使用的模板肯定是打印$ messages。

我檢查了非常類似的問題,但似乎並不適用。我的用戶0存在,這也是一個很老的答案。

任何幫助表示讚賞!

+0

不要在表單API中調用'drupal_goto'! '$ form_state ['redirect'] ='我/新/路徑' – 2013-02-27 23:48:25

+0

我沒有調用drupal_goto。 – Joren 2013-02-28 18:53:00

回答

0

嘗試使用hook_form_alter()添加自定義提交處理程序。一定要清除緩存,以便檢測到您的掛鉤。

function mymodule_form_user_register_form_alter(&$form, &$form_state) { 
    // Add a custom submit handler to the user register form 
    $form['#submit'][] = 'mymodule_custom_reg_handler'; 
} 

function mymodule_custom_reg_handler(&$form, &$form_state) { 
    drupal_set_message('Hi mom!'); 
} 
+0

這幾乎就是我所擁有的,這就是爲什麼我很困惑drupal不打印郵件。 :\ – Joren 2013-02-28 18:52:42

+0

嗯,我能想到的唯一的事情就是消息在類似代碼中的其他地方被清除了:'drupal_get_messages(NULL,TRUE)'。 – Coder1 2013-02-28 19:14:35