在 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
请注意,我不能抑制“必需”属性,因为它在其他地方以更“复杂”的形式使用。
谢谢