2011-05-10 78 views

回答

1

你無法去改變另一個驗證掛鉤。

你可以嘗試做的是構建自己的驗證,並在該窗體的驗證(['#validate'])數組只實例化自己的驗證掛鉤。

2

我能夠做出一個自定義模塊。它與sharedemail非常相似。

<?php 
function noemail_form_user_register_form_alter(&$form, &$form_state, $form_id) { 
    noemail_form_user_account_form_alter($form, $form_state, $form_id); 
} 
function noemail_form_user_profile_form_alter(&$form, &$form_state, $form_id) { 
    noemail_form_user_account_form_alter($form, $form_state, $form_id); 
} 
function noemail_form_user_account_form_alter(&$form, &$form_state, $form_id) { 
    if (is_array($form['#validate'])) { 
    $key = array_search('user_account_form_validate', $form['#validate'], TRUE); 
    if ($key !== FALSE) { 
     $form['#validate'][$key] = 'noemail_account_form_validate'; 
    } 
    } 
    $form['account']['mail']['#required'] = FALSE; 
} 
function noemail_account_form_validate($form, &$form_state) { 
    $form['account']['mail']['#needs_validation'] = false; 
} 

,並在情況下安裝文件是關鍵

<?php 
function sharedemail_install() { 
    db_query("UPDATE {system} SET weight = -99 WHERE name = 'noemail'"); 
} 

希望這有助於,哇,這是一個非常古老的線程。哦,並注意這是爲d7