我需要忽略兩個表單字段的驗證,同時創造在Drupal 6用戶,但我不知道一切是如何做到:Drupal的6 - 忽略所需的表單字段
$userinfo = array(
'name' => $login,
'init' => $mail,
'mail' => $mail,
'pass' => $password,
'status' => 1,
'lastname' => "", //how to ignore those required fields that invalidate the form
'surname' => "" //how to ignore those required fields that invalidate the form
);
// register a new user
$form_state = array();
$form_state['values'] = $userinfo;
drupal_execute('user_register', $form_state);
$errors = form_get_errors(); // getting 2 required field errors
注意,我可以不會壓制「所需」財產,因爲它在其他地方以更復雜的形式使用。
感謝
請不要在一個問兩個問題;如果您有兩個問題,請提出兩個不同的問題。 –
你說得對,謝謝 –